Skip to content

Commit 9536e92

Browse files
committed
Convert "example.go" into a real Go "Example" function (77% test coverage right off the bat!)
1 parent 818247f commit 9536e92

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

manifest/example.go renamed to manifest/example_test.go

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// +build ignore
2-
3-
package main
1+
package manifest_test
42

53
import (
64
"bufio"
@@ -10,8 +8,7 @@ import (
108
"github.com/docker-library/go-dockerlibrary/manifest"
119
)
1210

13-
func main() {
14-
// TODO comment parsing
11+
func Example() {
1512
man, err := manifest.Parse(bufio.NewReader(strings.NewReader(`# RFC 2822
1613
1714
# I LOVE CAKE
@@ -76,4 +73,49 @@ i: g@h j
7673
panic(err)
7774
}
7875
fmt.Printf("-------------\nline-based:\n%v\n", man)
76+
77+
// Output:
78+
// -------------
79+
// 2822:
80+
// Maintainers: InfoSiftr <[email protected]> (@infosiftr), Johan Euphrosine <[email protected]> (@proppy)
81+
// SharedTags: latest
82+
// GitRepo: https://github.com/docker-library/golang.git
83+
//
84+
// Tags: 1.6.1, 1.6, 1
85+
// GitCommit: 0ce80411b9f41e9c3a21fc0a1bffba6ae761825a
86+
// Directory: 1.6
87+
//
88+
// Tags: 1.5.3, 1.5
89+
// SharedTags: latest, 1.5.3-debian, 1.5-debian
90+
// GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
91+
// Directory: 1.5
92+
//
93+
// Shared Tag Groups:
94+
//
95+
// - latest
96+
// - 1.6.1, 1.6, 1
97+
// - 1.5.3, 1.5
98+
//
99+
// - 1.5.3-debian, 1.5-debian
100+
// - 1.5.3, 1.5
101+
//
102+
// -------------
103+
// line-based:
104+
// GitFetch: refs/heads/*
105+
//
106+
// Tags: a, e
107+
// GitRepo: b
108+
// GitCommit: c
109+
// Directory: d
110+
//
111+
// Tags: f
112+
// GitRepo: g
113+
// GitFetch: refs/tags/h
114+
// GitCommit: FETCH_HEAD
115+
//
116+
// Tags: i
117+
// GitRepo: g
118+
// GitFetch: refs/tags/h
119+
// GitCommit: FETCH_HEAD
120+
// Directory: j
79121
}

0 commit comments

Comments
 (0)