...
1
2
3
4
5
6
7
8
9
10
11
12
13
14 package util
15
16 import (
17 "os"
18 "testing"
19 )
20
21 func TestLoadSignerBinaryPath(t *testing.T) {
22 path, err := LoadSignerBinaryPath("./test_data/certificate_config.json")
23 if err != nil {
24 t.Errorf("LoadSignerBinaryPath error: %q", err)
25 }
26 want := "C:/Program Files (x86)/Google/Endpoint Verification/signer.exe"
27 if path != want {
28 t.Errorf("Expected path is %q, got: %q", want, path)
29 }
30 }
31
32 func TestLoadSignerBinaryPathHome(t *testing.T) {
33 path, err := LoadSignerBinaryPath("./test_data/certificate_config_home_expansion.json")
34 if err != nil {
35 t.Errorf("LoadSignerBinaryPath error: %q", err)
36 }
37 want := guessHomeDir() + "/ecp/signer"
38 if path != want {
39 t.Errorf("Expected path is %q, got: %q", want, path)
40 }
41 }
42
43 func TestLoadSignerBinaryPathTilde(t *testing.T) {
44 path, err := LoadSignerBinaryPath("./test_data/certificate_config_tilde_expansion.json")
45 if err != nil {
46 t.Errorf("LoadSignerBinaryPath error: %q", err)
47 }
48 want := guessHomeDir() + "/ecp/signer"
49 if path != want {
50 t.Errorf("Expected path is %q, got: %q", want, path)
51 }
52 }
53
54 func TestGetConfigFilePathFromEnv(t *testing.T) {
55 want := "/testpath"
56 os.Setenv("GOOGLE_API_CERTIFICATE_CONFIG", want)
57 path := GetConfigFilePathFromEnv()
58 if path != want {
59 t.Errorf("Expected path is %q, got: %q", want, path)
60 }
61 }
62
View as plain text