@@ -2,13 +2,13 @@ package manifest_test
2
2
3
3
import (
4
4
"bufio"
5
+ "fmt"
5
6
"strings"
6
- "testing"
7
7
8
8
"github.com/docker-library/go-dockerlibrary/manifest"
9
9
)
10
10
11
- func TestExample ( t * testing. T ) {
11
+ func Example ( ) {
12
12
man , err := manifest .Parse (bufio .NewReader (strings .NewReader (`# RFC 2822
13
13
14
14
# I LOVE CAKE
@@ -60,30 +60,20 @@ Tags: raspbian-s390x
60
60
Architectures: s390x, i386
61
61
62
62
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
73
63
` )))
74
64
if err != nil {
75
- t . Fatal (err )
65
+ panic (err )
76
66
}
77
- t . Logf ("-------------\n 2822:\n %s\n " , man )
67
+ fmt . Printf ("-------------\n 2822:\n %s\n " , man )
78
68
79
- t . Logf ("\n Shared Tag Groups:\n " )
69
+ fmt . Printf ("\n Shared Tag Groups:\n " )
80
70
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 , ", " ))
82
72
for _ , entry := range group .Entries {
83
- t . Logf (" - %s\n " , entry .TagsString ())
73
+ fmt . Printf (" - %s\n " , entry .TagsString ())
84
74
}
85
75
}
86
- t . Logf ("\n " )
76
+ fmt . Printf ("\n " )
87
77
88
78
man , err = manifest .Parse (bufio .NewReader (strings .NewReader (`
89
79
# maintainer: InfoSiftr <[email protected] > (@infosiftr)
@@ -100,7 +90,7 @@ i: g@h j
100
90
if err != nil {
101
91
panic (err )
102
92
}
103
- t . Logf ("-------------\n line-based:\n %v\n " , man )
93
+ fmt . Printf ("-------------\n line-based:\n %v\n " , man )
104
94
105
95
// Output:
106
96
// -------------
@@ -161,15 +151,15 @@ i: g@h j
161
151
// Directory: j
162
152
}
163
153
164
- func TestExampleFetch_local ( t * testing. T ) {
154
+ func ExampleFetch_local ( ) {
165
155
repoName , tagName , man , err := manifest .Fetch ("testdata" , "bash:4.4" )
166
156
if err != nil {
167
157
panic (err )
168
158
}
169
159
170
- t . Logf ("%s:%s\n \n " , repoName , tagName )
160
+ fmt . Printf ("%s:%s\n \n " , repoName , tagName )
171
161
172
- t . Log (man .GetTag (tagName ).ClearDefaults (manifest .DefaultManifestEntry ).String ())
162
+ fmt . Println (man .GetTag (tagName ).ClearDefaults (manifest .DefaultManifestEntry ).String ())
173
163
174
164
// Output:
175
165
// bash:4.4
@@ -181,15 +171,15 @@ func TestExampleFetch_local(t *testing.T) {
181
171
// Directory: 4.4
182
172
}
183
173
184
- func TestExampleFetch_remote ( t * testing. T ) {
174
+ func ExampleFetch_remote ( ) {
185
175
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" )
186
176
if err != nil {
187
177
panic (err )
188
178
}
189
179
190
- t . Logf ("%s:%s\n \n " , repoName , tagName )
180
+ fmt . Printf ("%s:%s\n \n " , repoName , tagName )
191
181
192
- t . Log (man .GetTag (tagName ).ClearDefaults (manifest .DefaultManifestEntry ).String ())
182
+ fmt . Println (man .GetTag (tagName ).ClearDefaults (manifest .DefaultManifestEntry ).String ())
193
183
194
184
// Output:
195
185
// bash:4.4
0 commit comments