@@ -553,7 +553,7 @@ func TestCLI(t *testing.T) {
553
553
songAPI := babyapi .NewAPI [* Song ]("Songs" , "/songs" , func () * Song { return & Song {} })
554
554
api .AddNestedAPI (songAPI )
555
555
go func () {
556
- err := api .RunWithArgs (os .Stdout , []string {"serve" }, 8080 , "" , false , nil , "" )
556
+ err := api .RunWithArgs (os .Stdout , []string {"serve" }, "localhost: 8080" , "" , false , nil , "" )
557
557
require .NoError (t , err )
558
558
}()
559
559
@@ -588,14 +588,14 @@ func TestCLI(t *testing.T) {
588
588
t .Run ("GetAllQueryParams" , func (t * testing.T ) {
589
589
t .Run ("Successful" , func (t * testing.T ) {
590
590
var out bytes.Buffer
591
- err := api .RunWithArgs (& out , []string {"list" , "Albums" }, 0 , address , false , nil , "title=New Album" )
591
+ err := api .RunWithArgs (& out , []string {"list" , "Albums" }, "" , address , false , nil , "title=New Album" )
592
592
require .NoError (t , err )
593
593
require .Equal (t , `{"items":[{"id":"cljcqg5o402e9s28rbp0","title":"New Album"}]}` , strings .TrimSpace (out .String ()))
594
594
})
595
595
596
596
t .Run ("NoMatch" , func (t * testing.T ) {
597
597
var out bytes.Buffer
598
- err := api .RunWithArgs (& out , []string {"list" , "Albums" }, 0 , address , false , nil , "title=badTitle" )
598
+ err := api .RunWithArgs (& out , []string {"list" , "Albums" }, "" , address , false , nil , "title=badTitle" )
599
599
require .NoError (t , err )
600
600
require .Equal (t , `{"items":[]}` , strings .TrimSpace (out .String ()))
601
601
})
@@ -604,7 +604,7 @@ func TestCLI(t *testing.T) {
604
604
for _ , tt := range tests {
605
605
t .Run (tt .name , func (t * testing.T ) {
606
606
var out bytes.Buffer
607
- err := api .RunWithArgs (& out , tt .args , 0 , address , false , nil , "" )
607
+ err := api .RunWithArgs (& out , tt .args , "" , address , false , nil , "" )
608
608
if ! tt .expectedErr {
609
609
require .NoError (t , err )
610
610
require .Regexp (t , tt .expectedRegexp , strings .TrimSpace (out .String ()))
@@ -942,7 +942,7 @@ func TestRootAPIAsChildOfResourceAPI(t *testing.T) {
942
942
artistAPI .AddNestedAPI (rootAPI )
943
943
944
944
go func () {
945
- err := artistAPI .RunWithArgs (os .Stdout , []string {"serve" }, 8080 , "" , false , nil , "" )
945
+ err := artistAPI .RunWithArgs (os .Stdout , []string {"serve" }, "localhost: 8080" , "" , false , nil , "" )
946
946
require .NoError (t , err )
947
947
}()
948
948
@@ -959,14 +959,14 @@ func TestRootAPIAsChildOfResourceAPI(t *testing.T) {
959
959
960
960
t .Run ("TestGetAllSongsEmpty" , func (t * testing.T ) {
961
961
var out bytes.Buffer
962
- err := artistAPI .RunWithArgs (& out , []string {"list" , "Songs" , artist1 .GetID ()}, 0 , address , false , nil , "" )
962
+ err := artistAPI .RunWithArgs (& out , []string {"list" , "Songs" , artist1 .GetID ()}, "" , address , false , nil , "" )
963
963
require .NoError (t , err )
964
964
require .Regexp (t , `{"items":\[\]}` , strings .TrimSpace (out .String ()))
965
965
})
966
966
967
967
t .Run ("CreateSong" , func (t * testing.T ) {
968
968
var out bytes.Buffer
969
- err := artistAPI .RunWithArgs (& out , []string {"post" , "Songs" , `{"title": "new song"}` , artist1 .GetID ()}, 0 , address , false , nil , "" )
969
+ err := artistAPI .RunWithArgs (& out , []string {"post" , "Songs" , `{"title": "new song"}` , artist1 .GetID ()}, "" , address , false , nil , "" )
970
970
require .NoError (t , err )
971
971
require .Regexp (t , `\{"id":"[0-9a-v]{20}","title":"new song"\}` , strings .TrimSpace (out .String ()))
972
972
})
@@ -1137,7 +1137,7 @@ func TestRootAPICLI(t *testing.T) {
1137
1137
AddNestedAPI (songAPI )
1138
1138
1139
1139
go func () {
1140
- err := rootAPI .RunWithArgs (os .Stdout , []string {"serve" }, 8080 , "" , false , nil , "" )
1140
+ err := rootAPI .RunWithArgs (os .Stdout , []string {"serve" }, "localhost: 8080" , "" , false , nil , "" )
1141
1141
require .NoError (t , err )
1142
1142
}()
1143
1143
@@ -1174,14 +1174,14 @@ func TestRootAPICLI(t *testing.T) {
1174
1174
t .Run ("GetAllQueryParams" , func (t * testing.T ) {
1175
1175
t .Run ("Successful" , func (t * testing.T ) {
1176
1176
var out bytes.Buffer
1177
- err := rootAPI .RunWithArgs (& out , []string {"list" , "MusicVideos" }, 0 , address , false , nil , "title=New Video" )
1177
+ err := rootAPI .RunWithArgs (& out , []string {"list" , "MusicVideos" }, "" , address , false , nil , "title=New Video" )
1178
1178
require .NoError (t , err )
1179
1179
require .Equal (t , `{"items":[{"id":"cljcqg5o402e9s28rbp0","title":"New Video"}]}` , strings .TrimSpace (out .String ()))
1180
1180
})
1181
1181
1182
1182
t .Run ("NoMatch" , func (t * testing.T ) {
1183
1183
var out bytes.Buffer
1184
- err := rootAPI .RunWithArgs (& out , []string {"list" , "MusicVideos" }, 0 , address , false , nil , "title=badTitle" )
1184
+ err := rootAPI .RunWithArgs (& out , []string {"list" , "MusicVideos" }, "" , address , false , nil , "title=badTitle" )
1185
1185
require .NoError (t , err )
1186
1186
require .Equal (t , `{"items":[]}` , strings .TrimSpace (out .String ()))
1187
1187
})
@@ -1190,7 +1190,7 @@ func TestRootAPICLI(t *testing.T) {
1190
1190
for _ , tt := range tests {
1191
1191
t .Run (tt .name , func (t * testing.T ) {
1192
1192
var out bytes.Buffer
1193
- err := rootAPI .RunWithArgs (& out , tt .args , 0 , address , false , nil , "" )
1193
+ err := rootAPI .RunWithArgs (& out , tt .args , "" , address , false , nil , "" )
1194
1194
if ! tt .expectedErr {
1195
1195
require .NoError (t , err )
1196
1196
require .Regexp (t , tt .expectedRegexp , strings .TrimSpace (out .String ()))
0 commit comments