-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup_test.go
42 lines (33 loc) · 840 Bytes
/
setup_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
package integration
import (
"flag"
"fmt"
"os"
"os/exec"
"path/filepath"
"testing"
)
// In these tests, there's a lot going on. Have a look at this article for a
// longer explanation:
// https://lucapette.me/writing/writing-integration-tests-for-a-go-cli-application
var update = flag.Bool("update", false, "update golden files")
const binaryName = "fakedata"
var binaryPath string
func TestMain(m *testing.M) {
err := os.Chdir("..")
if err != nil {
fmt.Printf("could not change dir: %v", err)
os.Exit(1)
}
abs, err := filepath.Abs(binaryName)
if err != nil {
fmt.Printf("could not get abs path for %s: %v", binaryName, err)
os.Exit(1)
}
binaryPath = abs
if err := exec.Command("make").Run(); err != nil {
fmt.Printf("could not make binary for %s: %v", binaryName, err)
os.Exit(1)
}
os.Exit(m.Run())
}