-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculate_test.go
55 lines (48 loc) · 1.56 KB
/
calculate_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
package calculate
import (
"testing"
"fmt"
"github.com/thisisfineio/common"
"github.com/alistanis/awstools/awsregions"
. "github.com/smartystreets/goconvey/convey"
)
/*
* The following tests will hit actual AWS Endpoints, so in order to run them you must actually have an account and
* the proper configurations set up
*/
func TestNewEC2(t *testing.T) {
Convey("We can get a new EC2 struct", t, func() {
ec2 := NewEC2(awsregions.USEast1)
So(ec2, ShouldNotBeNil)
})
}
func TestEC2_SetRegion(t *testing.T) {
Convey("We can change the region of an EC2 struct", t, func() {
ec2 := NewEC2(awsregions.AsiaNortheast1)
So(ec2, ShouldNotBeNil)
So(*ec2.service.Config.Region, ShouldEqual, awsregions.AsiaNortheast1)
ec2.SetRegion(awsregions.USEast1)
So(*ec2.service.Config.Region, ShouldEqual, awsregions.USEast1)
})
}
func TestEC2_DescribeInstances(t *testing.T) {
Convey("We can describe instances in our account", t, func() {
ec2 := NewEC2(awsregions.USEast1)
So(ec2, ShouldNotBeNil)
})
}
func TestNewCompute(t *testing.T) {
Convey("We can get a new compute interface with a valid provider, and an error when an invalid one is given", t, func() {
c, err := NewCompute(common.AwsProvider, awsregions.USEast1)
So(err, ShouldBeNil)
So(c.Provider(), ShouldEqual, common.AwsProvider)
_, err = NewCompute(-1, "no region")
e := err.(*common.Error)
So(e.Code, ShouldEqual, common.InvalidProviderErrCode)
Convey("We can test provider functions", func() {
instances, err := c.DescribeInstances(nil)
So(err, ShouldBeNil)
fmt.Println(instances)
})
})
}