@@ -17,6 +17,8 @@ import (
1717)
1818
1919func TestMessageSendValid (t * testing.T ) {
20+ binPath := testutils .RequireBinPath (t )
21+
2022 tests := []struct {
2123 name string
2224 message string
@@ -173,7 +175,7 @@ func TestMessageSendValid(t *testing.T) {
173175
174176 args = append (args , tt .message )
175177
176- cmd := exec .Command ("./smsgate" , args ... )
178+ cmd := exec .Command (binPath , args ... )
177179 cmd .Env = append ([]string {}, os .Environ ()... )
178180 cmd .Env = append (cmd .Env , fmt .Sprintf ("ASG_ENDPOINT=%s" , mockServer .URL ))
179181 cmd .Env = append (cmd .Env , "ASG_USERNAME=testuser" , "ASG_PASSWORD=testpass" )
@@ -194,6 +196,8 @@ func TestMessageSendValid(t *testing.T) {
194196}
195197
196198func TestMessageSendInvalid (t * testing.T ) {
199+ binPath := testutils .RequireBinPath (t )
200+
197201 tests := []struct {
198202 name string
199203 message string
@@ -277,7 +281,7 @@ func TestMessageSendInvalid(t *testing.T) {
277281
278282 args = append (args , tt .message )
279283
280- cmd := exec .Command ("./smsgate" , args ... )
284+ cmd := exec .Command (binPath , args ... )
281285 cmd .Env = append ([]string {}, os .Environ ()... )
282286 cmd .Env = append (cmd .Env , fmt .Sprintf ("ASG_ENDPOINT=%s" , mockServer .URL ))
283287 cmd .Env = append (cmd .Env , "ASG_USERNAME=testuser" , "ASG_PASSWORD=testpass" )
@@ -292,6 +296,8 @@ func TestMessageSendInvalid(t *testing.T) {
292296}
293297
294298func TestMessageSendAuthenticationError (t * testing.T ) {
299+ binPath := testutils .RequireBinPath (t )
300+
295301 mockServer := testutils .CreateMockServer (func (w http.ResponseWriter , r * http.Request ) {
296302 w .WriteHeader (http .StatusUnauthorized )
297303 w .Write ([]byte (`{"error": "Invalid credentials"}` ))
@@ -305,7 +311,7 @@ func TestMessageSendAuthenticationError(t *testing.T) {
305311 "Hello, world!" ,
306312 }
307313
308- cmd := exec .Command ("./smsgate" , args ... )
314+ cmd := exec .Command (binPath , args ... )
309315 cmd .Env = append ([]string {}, os .Environ ()... )
310316 cmd .Env = append (cmd .Env , fmt .Sprintf ("ASG_ENDPOINT=%s" , mockServer .URL ))
311317 cmd .Env = append (cmd .Env , "ASG_USERNAME=wronguser" , "ASG_PASSWORD=wrongpass" )
@@ -318,6 +324,8 @@ func TestMessageSendAuthenticationError(t *testing.T) {
318324}
319325
320326func TestMessageStatusValid (t * testing.T ) {
327+ binPath := testutils .RequireBinPath (t )
328+
321329 tests := []struct {
322330 name string
323331 messageID string
@@ -359,7 +367,7 @@ func TestMessageStatusValid(t *testing.T) {
359367 tt .messageID ,
360368 }
361369
362- cmd := exec .Command ("./smsgate" , args ... )
370+ cmd := exec .Command (binPath , args ... )
363371 cmd .Env = append ([]string {}, os .Environ ()... )
364372 cmd .Env = append (cmd .Env , fmt .Sprintf ("ASG_ENDPOINT=%s" , mockServer .URL ))
365373 cmd .Env = append (cmd .Env , "ASG_USERNAME=testuser" , "ASG_PASSWORD=testpass" )
@@ -379,6 +387,8 @@ func TestMessageStatusValid(t *testing.T) {
379387}
380388
381389func TestMessageStatusInvalid (t * testing.T ) {
390+ binPath := testutils .RequireBinPath (t )
391+
382392 tests := []struct {
383393 name string
384394 messageID string
@@ -409,7 +419,7 @@ func TestMessageStatusInvalid(t *testing.T) {
409419 args = append (args , tt .messageID )
410420 }
411421
412- cmd := exec .Command ("./smsgate" , args ... )
422+ cmd := exec .Command (binPath , args ... )
413423 cmd .Env = append ([]string {}, os .Environ ()... )
414424 cmd .Env = append (cmd .Env , fmt .Sprintf ("ASG_ENDPOINT=%s" , mockServer .URL ))
415425 cmd .Env = append (cmd .Env , "ASG_USERNAME=testuser" , "ASG_PASSWORD=testpass" )
@@ -424,6 +434,8 @@ func TestMessageStatusInvalid(t *testing.T) {
424434}
425435
426436func TestMessageCommandHelp (t * testing.T ) {
437+ binPath := testutils .RequireBinPath (t )
438+
427439 tests := []struct {
428440 name string
429441 args []string
@@ -447,7 +459,7 @@ func TestMessageCommandHelp(t *testing.T) {
447459 for _ , tt := range tests {
448460 t .Run (tt .name , func (t * testing.T ) {
449461 var stdout , stderr bytes.Buffer
450- cmd := exec .Command ("./smsgate" , tt .args ... )
462+ cmd := exec .Command (binPath , tt .args ... )
451463 cmd .Env = append ([]string {}, os .Environ ()... )
452464 cmd .Env = append (cmd .Env , "ASG_USERNAME=testuser" , "ASG_PASSWORD=testpass" )
453465 cmd .Stdout = & stdout
0 commit comments