This repository has been archived by the owner on Dec 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
config_test.go
85 lines (71 loc) · 1.63 KB
/
config_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package draft
import (
"fmt"
"net/http"
"net/http/httptest"
"testing"
)
func TestShowImplOpt(t *testing.T) {
cfg := NewConfig(ShowImpl(true))
if got := cfg.showImpl; got != true {
t.Errorf("got [%v] want [%v]", got, true)
}
ShowImpl(false)(&cfg)
if got := cfg.showImpl; got != false {
t.Errorf("got [%v] want [%v]", got, false)
}
}
func TestBottomTopOpt(t *testing.T) {
cfg := NewConfig()
BottomTop(true)(&cfg)
if got := cfg.bottomTop; got != true {
t.Errorf("got [%v] want [true]", got)
}
}
func TestVerboseOpt(t *testing.T) {
cfg := NewConfig()
Verbose(true)(&cfg)
if got := cfg.verbose; got != true {
t.Errorf("got [%v] want [true]", got)
}
}
func TestLoadFromHTTPUri(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, `title: Upload file to S3 using Lambda for pre-signed URL
backgroundColor: '#ffffff'
components:
-
kind: cli
label: "Web App"
impl: SPA
-
kind: gtw
-
kind: fun
label: Get Pre-Signed URL
-
kind: ost
label: "*.jpg\n*.png"`)
}))
defer ts.Close()
cfg := NewConfig(URI(ts.URL))
prj, err := Load(cfg)
if err != nil {
t.Error(err)
}
want := "Upload file to S3 using Lambda for pre-signed URL"
if got := prj.Title; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
if got := len(prj.Components); got != 4 {
t.Errorf("got [%v] want [3]", got)
}
want = "cli"
if got := prj.Components[0].Kind; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
want = "Get Pre-Signed URL"
if got := prj.Components[2].Label; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
}