@@ -141,7 +141,33 @@ func TestUpdateEndpointSuccessSingleSubdomain(t *testing.T) {
141
141
142
142
if assert .NoError (t , updateApi .HandleUpdateRequest (c )) {
143
143
assert .Equal (t , http .StatusOK , rec .Code )
144
- assert .Equal (t , "created 1 entries for subdomains bar on foo.com: 10.0.0.1" , rec .Body .String ())
144
+ assert .Equal (t , "created 1 entries on foo.com: 10.0.0.1" , rec .Body .String ())
145
+ }
146
+ }
147
+
148
+ func TestUpdateEndpointSuccessNoSubdomain (t * testing.T ) {
149
+ e := echo .New ()
150
+
151
+ q := make (url.Values )
152
+ q .Set ("domain" , "foo.com" )
153
+ q .Set ("ip" , "10.0.0.1" )
154
+ q .Set ("registrar" , "cloudflare" )
155
+
156
+ req := httptest .NewRequest (http .MethodGet , fmt .Sprintf ("/?%s" , q .Encode ()), nil )
157
+ rec := httptest .NewRecorder ()
158
+ c := e .NewContext (req , rec )
159
+
160
+ cs := mockservices .NewMockDnsUpdateService (t )
161
+ cs .On ("UpdateRecord" , mock .Anything ).Return (nil ).Once ()
162
+
163
+ sf := mockfactory .NewMockServiceFactory (t )
164
+ sf .On ("Find" , services .Registrar ("cloudflare" )).Return (cs , nil ).Once ()
165
+
166
+ updateApi = NewUpdateApi (sf )
167
+
168
+ if assert .NoError (t , updateApi .HandleUpdateRequest (c )) {
169
+ assert .Equal (t , http .StatusOK , rec .Code )
170
+ assert .Equal (t , "created 1 entries on foo.com: 10.0.0.1" , rec .Body .String ())
145
171
}
146
172
}
147
173
@@ -168,7 +194,7 @@ func TestUpdateEndpointSuccessThreeSubdomains(t *testing.T) {
168
194
169
195
if assert .NoError (t , updateApi .HandleUpdateRequest (c )) {
170
196
assert .Equal (t , http .StatusOK , rec .Code )
171
- assert .Equal (t , "created 3 entries for subdomains foo,bar,baz on foo.com: 10.0.0.1" , rec .Body .String ())
197
+ assert .Equal (t , "created 3 entries on foo.com: 10.0.0.1" , rec .Body .String ())
172
198
}
173
199
}
174
200
0 commit comments