-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unused function and add runner tests/mocks (#33)
- Loading branch information
1 parent
adbe68c
commit cd1239d
Showing
2 changed files
with
60 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,42 @@ | ||
package invocation | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/ssm" | ||
mocks "github.com/disneystreaming/ssm-helpers/testing" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetResult(t *testing.T) { | ||
assert := assert.New(t) | ||
mockSvc := &mocks.MockSSMClient{} | ||
|
||
successCmd, badCmd, mockInstance := | ||
aws.String("success-id"), aws.String("bad-id"), aws.String("i-123") | ||
|
||
oc := make(chan *ssm.GetCommandInvocationOutput) | ||
ec := make(chan error) | ||
|
||
t.Run("valid ID", func(t *testing.T) { | ||
go GetResult(mockSvc, successCmd, mockInstance, oc, ec) | ||
select { | ||
case result := <-oc: | ||
assert.Equal("success-id", *result.CommandId) | ||
case err := <-ec: | ||
assert.Empty(err) | ||
} | ||
|
||
}) | ||
|
||
t.Run("invalid ID", func(t *testing.T) { | ||
go GetResult(mockSvc, badCmd, mockInstance, oc, ec) | ||
select { | ||
case result := <-oc: | ||
assert.Empty(result) | ||
case err := <-ec: | ||
assert.Error(err) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters