-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgcloud_test.go
More file actions
29 lines (27 loc) · 847 Bytes
/
gcloud_test.go
File metadata and controls
29 lines (27 loc) · 847 Bytes
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
package main
import (
"fmt"
"testing"
)
func TestGcloudConfigSetProject(t *testing.T) {
cc := new(commandCapturer)
old := runCommand
runCommand = cc.runCommand
defer func() { runCommand = old }()
cfg := Config{Project: "p", Region: "r", Zone: "z"}
if err := gcloudConfigSetProject(cfg); err != nil {
t.Fatal(err)
}
if got, want := len(cc.args), 3; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
if got, want := fmt.Sprint(cc.args[0]), "[gcloud config set core/project p]"; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
if got, want := fmt.Sprint(cc.args[1]), "[gcloud config set compute/region r]"; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
if got, want := fmt.Sprint(cc.args[2]), "[gcloud config set compute/zone z]"; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
}