-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain_test.go
More file actions
39 lines (31 loc) · 678 Bytes
/
Copy pathmain_test.go
File metadata and controls
39 lines (31 loc) · 678 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
30
31
32
33
34
35
36
37
38
39
package main
import (
"fmt"
"io/ioutil"
"os"
"path"
"runtime"
"strings"
"testing"
)
//const TFVARS_BASE_PATH = "examples/terraform.tfvars"
func assert(o bool) {
if !o {
fmt.Printf("\n%c[35m%s%c[0m\n\n", 27, _GetRecentLine(), 27)
os.Exit(1)
}
}
func _GetRecentLine() string {
_, file, line, _ := runtime.Caller(2)
buf, _ := ioutil.ReadFile(file)
code := strings.TrimSpace(strings.Split(string(buf), "\n")[line-1])
return fmt.Sprintf("%v:%d\n%s", path.Base(file), line, code)
}
func TestMain(m *testing.M) {
assert(true)
}
func TestVersionInfo(t *testing.T) {
assert("unknown" == versionInfo())
buildVersion = "vXYZ"
assert("vXYZ" == versionInfo())
}