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