-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlambda_publish_version_test.go
52 lines (40 loc) · 1.4 KB
/
lambda_publish_version_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
package kanarya
import (
"os"
"strconv"
"strings"
"testing"
"time"
)
// TestPublishNewVersion publishes a new lambda version by calling
// PublishNewVersion and tests the output.
func TestPublishNewVersion(t *testing.T) {
lambdaClient := LambdaClient(os.Getenv("AWS_REGION"))
resp, err := PublishNewVersion(lambdaClient, testLambdaPackage)
if err != nil {
t.Fatalf("PublishNewVersion failed while publishing a new version. Err %v", err)
}
functionArn := resp.FunctionArn
vString := strings.Split(functionArn, ":")[7]
lastUpdateStatus := resp.LastUpdateStatus
state := resp.State
version := resp.Version
lastModifiedStr := strings.Split(resp.LastModified, ".")[0]
lastModifiedTime, err := time.Parse("2006-01-02T15:04:05", lastModifiedStr)
if err != nil {
t.Fatalf("Can not parse lastModifiedTime (%v) returned by PublishNewVersion. Err %v", lastModifiedTime, err)
}
vInt, err := strconv.Atoi(vString)
if err != nil {
t.Fatalf("PublishNewVersion should return a new ARN for new version, but returned %v", vInt)
}
if lastUpdateStatus != "Successful" {
t.Fatalf("PublishNewVersion should return a successful status, but returned %v", lastUpdateStatus)
}
if state != "Active" {
t.Fatalf("PublishNewVersion should return an active state, but returned %v", state)
}
if version != vString {
t.Fatalf("PublishNewVersion should return a new version number, but returned %v", version)
}
}