@@ -2,13 +2,13 @@ package manifest_test
22
33import (
44 "bufio"
5+ "fmt"
56 "strings"
6- "testing"
77
88 "github.com/docker-library/go-dockerlibrary/manifest"
99)
1010
11- func TestExample ( t * testing. T ) {
11+ func Example ( ) {
1212 man , err := manifest .Parse (bufio .NewReader (strings .NewReader (`# RFC 2822
1313
1414 # I LOVE CAKE
@@ -60,30 +60,20 @@ 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
7363` )))
7464 if err != nil {
75- t . Fatal (err )
65+ panic (err )
7666 }
77- t . Logf ("-------------\n 2822:\n %s\n " , man )
67+ fmt . Printf ("-------------\n 2822:\n %s\n " , man )
7868
79- t . Logf ("\n Shared Tag Groups:\n " )
69+ fmt . Printf ("\n Shared Tag Groups:\n " )
8070 for _ , group := range man .GetSharedTagGroups () {
81- t . Logf ("\n - %s\n " , strings .Join (group .SharedTags , ", " ))
71+ fmt . Printf ("\n - %s\n " , strings .Join (group .SharedTags , ", " ))
8272 for _ , entry := range group .Entries {
83- t . Logf (" - %s\n " , entry .TagsString ())
73+ fmt . Printf (" - %s\n " , entry .TagsString ())
8474 }
8575 }
86- t . Logf ("\n " )
76+ fmt . Printf ("\n " )
8777
8878 man , err = manifest .Parse (bufio .NewReader (strings .NewReader (`
8979# maintainer: InfoSiftr <github@infosiftr.com> (@infosiftr)
@@ -100,7 +90,7 @@ i: g@h j
10090 if err != nil {
10191 panic (err )
10292 }
103- t . Logf ("-------------\n line-based:\n %v\n " , man )
93+ fmt . Printf ("-------------\n line-based:\n %v\n " , man )
10494
10595 // Output:
10696 // -------------
@@ -161,15 +151,15 @@ i: g@h j
161151 // Directory: j
162152}
163153
164- func TestExampleFetch_local ( t * testing. T ) {
154+ func ExampleFetch_local ( ) {
165155 repoName , tagName , man , err := manifest .Fetch ("testdata" , "bash:4.4" )
166156 if err != nil {
167157 panic (err )
168158 }
169159
170- t . Logf ("%s:%s\n \n " , repoName , tagName )
160+ fmt . Printf ("%s:%s\n \n " , repoName , tagName )
171161
172- t . Log (man .GetTag (tagName ).ClearDefaults (manifest .DefaultManifestEntry ).String ())
162+ fmt . Println (man .GetTag (tagName ).ClearDefaults (manifest .DefaultManifestEntry ).String ())
173163
174164 // Output:
175165 // bash:4.4
@@ -181,15 +171,15 @@ func TestExampleFetch_local(t *testing.T) {
181171 // Directory: 4.4
182172}
183173
184- func TestExampleFetch_remote ( t * testing. T ) {
174+ func ExampleFetch_remote ( ) {
185175 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" )
186176 if err != nil {
187177 panic (err )
188178 }
189179
190- t . Logf ("%s:%s\n \n " , repoName , tagName )
180+ fmt . Printf ("%s:%s\n \n " , repoName , tagName )
191181
192- t . Log (man .GetTag (tagName ).ClearDefaults (manifest .DefaultManifestEntry ).String ())
182+ fmt . Println (man .GetTag (tagName ).ClearDefaults (manifest .DefaultManifestEntry ).String ())
193183
194184 // Output:
195185 // bash:4.4
0 commit comments