@@ -2,13 +2,13 @@ package manifest_test
22
33import (
44 "bufio"
5- "fmt"
65 "strings"
6+ "testing"
77
88 "github.com/docker-library/go-dockerlibrary/manifest"
99)
1010
11- func Example ( ) {
11+ func TestExample ( t * testing. T ) {
1212 man , err := manifest .Parse (bufio .NewReader (strings .NewReader (`# RFC 2822
1313
1414 # I LOVE CAKE
@@ -60,20 +60,30 @@ Tags: raspbian-s390x
6060Architectures: s390x, i386
6161
6262
63+ Tags: 1.5-withfile
64+ SharedTags: 1.5-debian
65+ GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
66+ File: Dockerfile-15
67+
68+ Tags: 1.5-withdirandfile
69+ SharedTags: 1.5-debian
70+ GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
71+ Directory: 1.5
72+ File: Dockerfile-debian
6373` )))
6474 if err != nil {
65- panic (err )
75+ t . Fatal (err )
6676 }
67- fmt . Printf ("-------------\n 2822:\n %s\n " , man )
77+ t . Logf ("-------------\n 2822:\n %s\n " , man )
6878
69- fmt . Printf ("\n Shared Tag Groups:\n " )
79+ t . Logf ("\n Shared Tag Groups:\n " )
7080 for _ , group := range man .GetSharedTagGroups () {
71- fmt . Printf ("\n - %s\n " , strings .Join (group .SharedTags , ", " ))
81+ t . Logf ("\n - %s\n " , strings .Join (group .SharedTags , ", " ))
7282 for _ , entry := range group .Entries {
73- fmt . Printf (" - %s\n " , entry .TagsString ())
83+ t . Logf (" - %s\n " , entry .TagsString ())
7484 }
7585 }
76- fmt . Printf ("\n " )
86+ t . Logf ("\n " )
7787
7888 man , err = manifest .Parse (bufio .NewReader (strings .NewReader (`
7989# maintainer: InfoSiftr <github@infosiftr.com> (@infosiftr)
@@ -90,7 +100,7 @@ i: g@h j
90100 if err != nil {
91101 panic (err )
92102 }
93- fmt . Printf ("-------------\n line-based:\n %v\n " , man )
103+ t . Logf ("-------------\n line-based:\n %v\n " , man )
94104
95105 // Output:
96106 // -------------
@@ -151,15 +161,15 @@ i: g@h j
151161 // Directory: j
152162}
153163
154- func ExampleFetch_local ( ) {
164+ func TestExampleFetch_local ( t * testing. T ) {
155165 repoName , tagName , man , err := manifest .Fetch ("testdata" , "bash:4.4" )
156166 if err != nil {
157167 panic (err )
158168 }
159169
160- fmt . Printf ("%s:%s\n \n " , repoName , tagName )
170+ t . Logf ("%s:%s\n \n " , repoName , tagName )
161171
162- fmt . Println (man .GetTag (tagName ).ClearDefaults (manifest .DefaultManifestEntry ).String ())
172+ t . Log (man .GetTag (tagName ).ClearDefaults (manifest .DefaultManifestEntry ).String ())
163173
164174 // Output:
165175 // bash:4.4
@@ -171,15 +181,15 @@ func ExampleFetch_local() {
171181 // Directory: 4.4
172182}
173183
174- func ExampleFetch_remote ( ) {
184+ func TestExampleFetch_remote ( t * testing. T ) {
175185 repoName , tagName , man , err := manifest .Fetch ("/home/jsmith/docker/official-images/library" , "https://github.com/docker-library/official-images/raw/1a3c4cd6d5cd53bd538a6f56a69f94c5b35325a7/library/bash:4.4" )
176186 if err != nil {
177187 panic (err )
178188 }
179189
180- fmt . Printf ("%s:%s\n \n " , repoName , tagName )
190+ t . Logf ("%s:%s\n \n " , repoName , tagName )
181191
182- fmt . Println (man .GetTag (tagName ).ClearDefaults (manifest .DefaultManifestEntry ).String ())
192+ t . Log (man .GetTag (tagName ).ClearDefaults (manifest .DefaultManifestEntry ).String ())
183193
184194 // Output:
185195 // bash:4.4
0 commit comments