44 "bytes"
55 "encoding/json"
66 "fmt"
7- "io/ioutil"
87 "os"
98 "testing"
109
@@ -20,9 +19,7 @@ func TestCheckFailsWithoutConfig(t *testing.T) {
2019 b := bytes .NewBufferString ("" )
2120 checkCommand .SetOut (b )
2221 checkCommand .Execute ()
23- out , err := ioutil .ReadAll (b )
24- assert .NoError (t , err )
25- assert .Equal (t , "Please provide path to a valid configuration file\n " , string (out ))
22+ assert .Equal (t , "Please provide path to a valid configuration file\n " , b .String ())
2623}
2724
2825func TestCheckInvalidCatalogJSON (t * testing.T ) {
@@ -35,15 +32,13 @@ func TestCheckInvalidCatalogJSON(t *testing.T) {
3532 Logger : internal .NewLogger (os .Stdout ),
3633 })
3734 b := bytes .NewBufferString ("" )
38-
3935 checkCommand .SetArgs ([]string {"config source.json" })
4036 checkCommand .SetOut (b )
4137 checkCommand .Flag ("config" ).Value .Set ("catalog.json" )
4238 checkCommand .Execute ()
43- out , err := ioutil .ReadAll (b )
44- assert .NoError (t , err )
39+
4540 var amsg internal.AirbyteMessage
46- err = json .Unmarshal ( out , & amsg )
41+ err : = json .NewDecoder ( b ). Decode ( & amsg )
4742 assert .NoError (t , err )
4843 assert .Equal (t , internal .CONNECTION_STATUS , amsg .Type )
4944 require .NotNil (t , amsg .ConnectionStatus )
@@ -70,10 +65,9 @@ func TestCheckCredentialsInvalid(t *testing.T) {
7065 checkCommand .SetOut (b )
7166 checkCommand .Flag ("config" ).Value .Set ("catalog.json" )
7267 checkCommand .Execute ()
73- out , err := ioutil .ReadAll (b )
74- assert .NoError (t , err )
68+
7569 var amsg internal.AirbyteMessage
76- err = json .Unmarshal ( out , & amsg )
70+ err : = json .NewDecoder ( b ). Decode ( & amsg )
7771 require .NoError (t , err )
7872 assert .Equal (t , internal .CONNECTION_STATUS , amsg .Type )
7973 assert .NotNil (t , amsg .ConnectionStatus )
@@ -102,10 +96,9 @@ func TestCheckExecuteSuccessful(t *testing.T) {
10296
10397 checkCommand .Flag ("config" ).Value .Set ("catalog.json" )
10498 checkCommand .Execute ()
105- out , err := ioutil .ReadAll (b )
106- assert .NoError (t , err )
99+
107100 var amsg internal.AirbyteMessage
108- err = json .Unmarshal ( out , & amsg )
101+ err : = json .NewDecoder ( b ). Decode ( & amsg )
109102 require .NoError (t , err )
110103 assert .Equal (t , internal .CONNECTION_STATUS , amsg .Type )
111104 assert .NotNil (t , amsg .ConnectionStatus )
0 commit comments