-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathmain_test.go
More file actions
35 lines (31 loc) · 824 Bytes
/
main_test.go
File metadata and controls
35 lines (31 loc) · 824 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
package main
import (
"net/http/httptest"
"os"
"testing"
)
// Not a fan of globals, but it's the only sane way to pass an httptest instance into each of the tests...
var (
testServer *httptest.Server
)
func TestMain(m *testing.M) {
// Setup the test API
app := &App{}
// Mock parameters
app.AmiID = "ami-asdfasdf"
app.AvailabilityZone = "us-east-1a"
// AppPort not required
app.Hostname = "testhostname"
app.InstanceID = "i-asdfasdf"
app.InstanceType = "t2.micro"
app.MacAddress = "00:aa:bb:cc:dd:ee"
app.MockInstanceProfile = true
app.PrivateIp = "10.20.30.40"
app.RoleName = "some-instance-profile"
// No RoleArn or RoleName needed for current test coverage
app.VpcID = "vpc-asdfasdf"
testServer = httptest.NewServer(app.NewServer())
defer testServer.Close()
// Run the tests
os.Exit(m.Run())
}