Skip to content

Commit 81cd21f

Browse files
author
Aaron Schlesinger
committed
fix(pkg/gitreceive/storage/auth_test.go): add preliminary tests for getAuth
1 parent a1c4d12 commit 81cd21f

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package storage
2+
3+
import (
4+
"testing"
5+
6+
"github.com/arschles/assert"
7+
"github.com/aws/aws-sdk-go/aws/credentials"
8+
"github.com/deis/builder/pkg/sys"
9+
)
10+
11+
func TestGetAuthEmptyAuth(t *testing.T) {
12+
fs := sys.NewFakeFS()
13+
creds, err := getAuth(fs)
14+
assert.NoErr(t, err)
15+
assert.Equal(t, creds, credentials.AnonymousCredentials, "returned credentials")
16+
}
17+
18+
func TestGetAuthMissingKey(t *testing.T) {
19+
fs := sys.NewFakeFS()
20+
fs.Files[accessSecretKeyFile] = []byte("hello world")
21+
creds, err := getAuth(fs)
22+
assert.Err(t, err, errMissingKey)
23+
assert.True(t, creds == nil, "returned credentials were not nil")
24+
}
25+
26+
func TestGetAuthMissingSecret(t *testing.T) {
27+
fs := sys.NewFakeFS()
28+
fs.Files[accessKeyIDFile] = []byte("hello world")
29+
creds, err := getAuth(fs)
30+
assert.Err(t, err, errMissingSecret)
31+
assert.True(t, creds == nil, "returned credentials were not nil")
32+
}

0 commit comments

Comments
 (0)