-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
41 lines (35 loc) · 932 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"testing"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/aws/aws-sdk-go/service/iam/iamiface"
)
type mockIAMClient struct {
iamiface.IAMAPI
}
var dummyUser = &iam.User{
Arn: aws.String("asdj910jd823hf298hf923ghf923h"),
CreateDate: aws.Time(time.Now()),
PasswordLastUsed: aws.Time(time.Now()),
Path: aws.String("/"),
UserId: aws.String("AKIAIWGSMDPM4875FVZA"),
UserName: aws.String("mockUser"),
}
var dummyGetUserOutput = &iam.GetUserOutput{
User: dummyUser,
}
func (m *mockIAMClient) GetUser(input *iam.GetUserInput) (*iam.GetUserOutput, error) {
return dummyGetUserOutput, nil
}
func TestGetUserName(t *testing.T) {
var dummyClient = &Client{iam: &mockIAMClient{}}
user, err := dummyClient.getUserName()
if err != nil {
t.Fatal(err)
}
if user != "mockUser" {
t.Fatalf("Wrong user")
}
}