forked from azer/go-flickr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
47 lines (40 loc) · 1.15 KB
/
client_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
42
43
44
45
46
47
//go:build unit
// +build unit
package flickr
import (
"testing"
)
func TestNewClientSpecifiedApiKey(t *testing.T) {
expectedApiKey := "my-api-key"
sut := &Client{Key: expectedApiKey}
if sut.Key != expectedApiKey {
t.Errorf("Expecting API Key '%s', but got '%s'", expectedApiKey, sut.Key)
}
}
// func TestNewClientEnvFile(t *testing.T) {
// // Temporarily unset any API Key that is set
// apiKey, keyExists := os.LookupEnv(ApiKeyEnvVar)
// if keyExists {
// os.Unsetenv(ApiKeyEnvVar)
// t.Cleanup(func() {
// os.Setenv(ApiKeyEnvVar, apiKey)
// })
// }
// // Create a temporary env file
// file, err := ioutil.TempFile("", "go-test")
// if err != nil {
// t.Errorf("Unable to create temp env file: %s", err)
// }
// defer os.Remove(file.Name())
// // Write API key to file
// expectedApiKey := "my-api-key"
// file.WriteString(fmt.Sprintf("%s=%s", ApiKeyEnvVar, expectedApiKey))
// file.Close()
// sut, err := NewClientEnvFile(file.Name())
// if err != nil {
// t.Fatalf("Unable to create client: %s", err)
// }
// if sut.Key != expectedApiKey {
// t.Errorf("Expecting API Key '%s', but got '%s'", expectedApiKey, sut.Key)
// }
// }