forked from camptocamp/terraboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
39 lines (29 loc) · 877 Bytes
/
main_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
package main
import (
"net/http"
"testing"
"github.com/camptocamp/terraboard/db"
"gorm.io/gorm"
)
func TestIsKnownStateVersion_Match(t *testing.T) {
statesVersions := map[string][]string{
"fakeVersionID": {"myfakepath/terraform.tfstate"},
}
if !isKnownStateVersion(statesVersions, "fakeVersionID", "myfakepath/terraform.tfstate") {
t.Fatalf("Expected %t, got %t", true, false)
}
}
func TestIsKnownStateVersion_NoMatch(t *testing.T) {
statesVersions := map[string][]string{
"fakeVersionID": {"myfakepath/terraform.tfstate"},
}
if isKnownStateVersion(statesVersions, "VersionID", "myfakepath/terraform.tfstate") {
t.Fatalf("Expected %t, got %t", false, true)
}
}
func handlerWithDB(w http.ResponseWriter, r *http.Request, d *db.Database) {
}
func TestHandleWithDB(t *testing.T) {
d := db.Database{DB: &gorm.DB{}}
handleWithDB(handlerWithDB, &d)
}