8
8
9
9
"github.com/github/git-lfs/api"
10
10
"github.com/github/git-lfs/config"
11
- "github.com/stretchr/testify/suite "
11
+ "github.com/stretchr/testify/assert "
12
12
)
13
13
14
14
type NopEndpointSource struct {
@@ -23,34 +23,24 @@ var (
23
23
source = & NopEndpointSource {"https://example.com" }
24
24
)
25
25
26
- func TestHttpLifecycleSuite (t * testing.T ) {
27
- suite .Run (t , new (HttpLifecycleTestSuite ))
28
- }
29
-
30
- type HttpLifecycleTestSuite struct {
31
- suite.Suite
32
- }
33
-
34
- func (suite * HttpLifecycleTestSuite ) SetupTest () {
26
+ func TestHttpLifecycleMakesRequestsAgainstAbsolutePath (t * testing.T ) {
35
27
SetupTestCredentialsFunc ()
36
- }
28
+ defer RestoreCredentialsFunc ()
37
29
38
- func (suite * HttpLifecycleTestSuite ) TearDownTest () {
39
- RestoreCredentialsFunc ()
40
- }
41
-
42
- func (suite * HttpLifecycleTestSuite ) TestHttpLifecycleMakesRequestsAgainstAbsolutePath () {
43
30
l := api .NewHttpLifecycle (source )
44
31
req , err := l .Build (& api.RequestSchema {
45
32
Path : "/foo" ,
46
33
Operation : api .DownloadOperation ,
47
34
})
48
35
49
- suite . Assert (). Nil (err )
50
- suite . Assert (). Equal ("https://example.com/foo" , req .URL .String ())
36
+ assert . Nil (t , err )
37
+ assert . Equal (t , "https://example.com/foo" , req .URL .String ())
51
38
}
52
39
53
- func (suite * HttpLifecycleTestSuite ) TestHttpLifecycleAttachesQueryParameters () {
40
+ func TestHttpLifecycleAttachesQueryParameters (t * testing.T ) {
41
+ SetupTestCredentialsFunc ()
42
+ defer RestoreCredentialsFunc ()
43
+
54
44
l := api .NewHttpLifecycle (source )
55
45
req , err := l .Build (& api.RequestSchema {
56
46
Path : "/foo" ,
@@ -60,11 +50,14 @@ func (suite *HttpLifecycleTestSuite) TestHttpLifecycleAttachesQueryParameters()
60
50
},
61
51
})
62
52
63
- suite . Assert (). Nil (err )
64
- suite . Assert (). Equal ("https://example.com/foo?a=b" , req .URL .String ())
53
+ assert . Nil (t , err )
54
+ assert . Equal (t , "https://example.com/foo?a=b" , req .URL .String ())
65
55
}
66
56
67
- func (suite * HttpLifecycleTestSuite ) TestHttpLifecycleAttachesBodyWhenPresent () {
57
+ func TestHttpLifecycleAttachesBodyWhenPresent (t * testing.T ) {
58
+ SetupTestCredentialsFunc ()
59
+ defer RestoreCredentialsFunc ()
60
+
68
61
l := api .NewHttpLifecycle (source )
69
62
req , err := l .Build (& api.RequestSchema {
70
63
Operation : api .DownloadOperation ,
@@ -73,39 +66,48 @@ func (suite *HttpLifecycleTestSuite) TestHttpLifecycleAttachesBodyWhenPresent()
73
66
}{"bar" },
74
67
})
75
68
76
- suite . Assert (). Nil (err )
69
+ assert . Nil (t , err )
77
70
78
71
body , err := ioutil .ReadAll (req .Body )
79
- suite . Assert (). Nil (err )
80
- suite . Assert (). Equal ("{\" foo\" :\" bar\" }" , string (body ))
72
+ assert . Nil (t , err )
73
+ assert . Equal (t , "{\" foo\" :\" bar\" }" , string (body ))
81
74
}
82
75
83
- func (suite * HttpLifecycleTestSuite ) TestHttpLifecycleDoesNotAttachBodyWhenEmpty () {
76
+ func TestHttpLifecycleDoesNotAttachBodyWhenEmpty (t * testing.T ) {
77
+ SetupTestCredentialsFunc ()
78
+ defer RestoreCredentialsFunc ()
79
+
84
80
l := api .NewHttpLifecycle (source )
85
81
req , err := l .Build (& api.RequestSchema {
86
82
Operation : api .DownloadOperation ,
87
83
})
88
84
89
- suite . Assert (). Nil (err )
90
- suite . Assert (). Nil (req .Body )
85
+ assert . Nil (t , err )
86
+ assert . Nil (t , req .Body )
91
87
}
92
88
93
- func (suite * HttpLifecycleTestSuite ) TestHttpLifecycleErrsWithoutOperation () {
89
+ func TestHttpLifecycleErrsWithoutOperation (t * testing.T ) {
90
+ SetupTestCredentialsFunc ()
91
+ defer RestoreCredentialsFunc ()
92
+
94
93
l := api .NewHttpLifecycle (source )
95
94
req , err := l .Build (& api.RequestSchema {
96
95
Path : "/foo" ,
97
96
})
98
97
99
- suite . Assert (). Equal (api .ErrNoOperationGiven , err )
100
- suite . Assert (). Nil (req )
98
+ assert . Equal (t , api .ErrNoOperationGiven , err )
99
+ assert . Nil (t , req )
101
100
}
102
101
103
- func (suite * HttpLifecycleTestSuite ) TestHttpLifecycleExecutesRequestWithoutBody () {
102
+ func TestHttpLifecycleExecutesRequestWithoutBody (t * testing.T ) {
103
+ SetupTestCredentialsFunc ()
104
+ defer RestoreCredentialsFunc ()
105
+
104
106
var called bool
105
107
server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
106
108
called = true
107
109
108
- suite . Assert (). Equal ("/path" , r .URL .RequestURI ())
110
+ assert . Equal (t , "/path" , r .URL .RequestURI ())
109
111
}))
110
112
defer server .Close ()
111
113
@@ -114,11 +116,14 @@ func (suite *HttpLifecycleTestSuite) TestHttpLifecycleExecutesRequestWithoutBody
114
116
l := api .NewHttpLifecycle (source )
115
117
_ , err := l .Execute (req , nil )
116
118
117
- suite . Assert (). True (called )
118
- suite . Assert (). Nil (err )
119
+ assert . True (t , called )
120
+ assert . Nil (t , err )
119
121
}
120
122
121
- func (suite * HttpLifecycleTestSuite ) TestHttpLifecycleExecutesRequestWithBody () {
123
+ func TestHttpLifecycleExecutesRequestWithBody (t * testing.T ) {
124
+ SetupTestCredentialsFunc ()
125
+ defer RestoreCredentialsFunc ()
126
+
122
127
type Response struct {
123
128
Foo string `json:"foo"`
124
129
}
@@ -137,7 +142,7 @@ func (suite *HttpLifecycleTestSuite) TestHttpLifecycleExecutesRequestWithBody()
137
142
resp := new (Response )
138
143
_ , err := l .Execute (req , resp )
139
144
140
- suite . Assert (). True (called )
141
- suite . Assert (). Nil (err )
142
- suite . Assert (). Equal ("bar" , resp .Foo )
145
+ assert . True (t , called )
146
+ assert . Nil (t , err )
147
+ assert . Equal (t , "bar" , resp .Foo )
143
148
}
0 commit comments