Skip to content

Commit 61055e4

Browse files
authored
Merge pull request #9 from infosiftr/TestParseError
Add a simple test for a "manifest.Parse" error
2 parents 65c107f + ae1ac32 commit 61055e4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

manifest/parse_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package manifest_test
2+
3+
import (
4+
"strings"
5+
"testing"
6+
7+
"github.com/docker-library/go-dockerlibrary/manifest"
8+
)
9+
10+
func TestParseError(t *testing.T) {
11+
invalidManifest := `this is just completely bogus and invalid no matter how you slice it`
12+
13+
man, err := manifest.Parse(strings.NewReader(invalidManifest))
14+
if err == nil {
15+
t.Errorf("Expected error, got valid manifest instead:\n%s", man)
16+
}
17+
if !strings.HasPrefix(err.Error(), "cannot parse manifest in either format:") {
18+
t.Errorf("Unexpected error: %v", err)
19+
}
20+
}

0 commit comments

Comments
 (0)