@@ -8,23 +8,25 @@ import (
8
8
"net/url"
9
9
"os"
10
10
"os/exec"
11
+ "path/filepath"
11
12
"strings"
12
13
14
+ "github.com/aws/copilot-cli/e2e/internal/client"
15
+
13
16
. "github.com/onsi/ginkgo"
14
17
. "github.com/onsi/gomega"
15
18
)
16
19
17
20
var _ = Describe ("pipeline flow" , func () {
18
21
Context ("setup CodeCommit repository" , func () {
19
- var cloneURL string
20
22
It ("creates the codecommit repository" , func () {
21
23
url , err := aws .CreateCodeCommitRepo (repoName )
22
24
Expect (err ).NotTo (HaveOccurred ())
23
- cloneURL = url
25
+ repoURL = url
24
26
})
25
27
26
28
It ("clones the repository" , func () {
27
- endpoint := strings .TrimPrefix (cloneURL , "https://" )
29
+ endpoint := strings .TrimPrefix (repoURL , "https://" )
28
30
url := fmt .Sprintf ("https://%s:%s@%s" , url .PathEscape (codeCommitCreds .UserName ), url .PathEscape (codeCommitCreds .Password ), endpoint )
29
31
30
32
Eventually (func () error {
@@ -44,16 +46,111 @@ var _ = Describe("pipeline flow", func() {
44
46
45
47
It ("should push upstream" , func () {
46
48
cmd := exec .Command ("git" , "add" , "." )
49
+ cmd .Stdout = os .Stdout
50
+ cmd .Stderr = os .Stderr
47
51
cmd .Dir = repoName
48
52
Expect (cmd .Run ()).NotTo (HaveOccurred ())
49
53
50
54
cmd = exec .Command ("git" , "commit" , "-m" , "first commit" )
55
+ cmd .Stdout = os .Stdout
56
+ cmd .Stderr = os .Stderr
51
57
cmd .Dir = repoName
52
58
Expect (cmd .Run ()).NotTo (HaveOccurred ())
53
59
54
60
cmd = exec .Command ("git" , "push" )
61
+ cmd .Stdout = os .Stdout
62
+ cmd .Stderr = os .Stderr
55
63
cmd .Dir = repoName
56
64
Expect (cmd .Run ()).NotTo (HaveOccurred ())
57
65
})
58
66
})
67
+
68
+ Context ("create a new app" , func () {
69
+ It ("app init succeeds" , func () {
70
+ _ , err := copilot .AppInit (& client.AppInitRequest {
71
+ AppName : appName ,
72
+ })
73
+ Expect (err ).NotTo (HaveOccurred ())
74
+ })
75
+ It ("app init creates an copilot directory and workspace file" , func () {
76
+ Expect (filepath .Join (repoName , "copilot" )).Should (BeADirectory ())
77
+ Expect (filepath .Join (repoName , "copilot" , ".workspace" )).Should (BeAnExistingFile ())
78
+ })
79
+ It ("app ls includes new app" , func () {
80
+ Eventually (copilot .AppList , "30s" , "5s" ).Should (ContainSubstring (appName ))
81
+ })
82
+ It ("app show includes app name" , func () {
83
+ appShowOutput , err := copilot .AppShow (appName )
84
+ Expect (err ).NotTo (HaveOccurred ())
85
+ Expect (appShowOutput .Name ).To (Equal (appName ))
86
+ Expect (appShowOutput .URI ).To (BeEmpty ())
87
+ })
88
+ })
89
+
90
+ Context ("when creating a new environment" , func () {
91
+ It ("test env init should succeed" , func () {
92
+ _ , err := copilot .EnvInit (& client.EnvInitRequest {
93
+ AppName : appName ,
94
+ EnvName : "test" ,
95
+ Profile : "e2etestenv" ,
96
+ Prod : false ,
97
+ })
98
+ Expect (err ).NotTo (HaveOccurred ())
99
+ })
100
+ It ("prod env init should succeed" , func () {
101
+ _ , err := copilot .EnvInit (& client.EnvInitRequest {
102
+ AppName : appName ,
103
+ EnvName : "prod" ,
104
+ Profile : "e2eprodenv" ,
105
+ Prod : false ,
106
+ })
107
+ Expect (err ).NotTo (HaveOccurred ())
108
+ })
109
+ It ("env ls should list both envs" , func () {
110
+ out , err := copilot .EnvList (appName )
111
+ Expect (err ).NotTo (HaveOccurred ())
112
+ Expect (len (out .Envs )).To (Equal (2 ))
113
+ envs := map [string ]client.EnvDescription {}
114
+ for _ , env := range out .Envs {
115
+ envs [env .Name ] = env
116
+ Expect (env .ExecutionRole ).NotTo (BeEmpty ())
117
+ Expect (env .ManagerRole ).NotTo (BeEmpty ())
118
+ }
119
+
120
+ Expect (envs ["test" ]).NotTo (BeNil ())
121
+ Expect (envs ["prod" ]).NotTo (BeNil ())
122
+ })
123
+ })
124
+
125
+ Context ("when creating the frontend service" , func () {
126
+ It ("should initialize the service" , func () {
127
+ _ , err := copilot .SvcInit (& client.SvcInitRequest {
128
+ Name : "frontend" ,
129
+ SvcType : "Load Balanced Web Service" ,
130
+ Dockerfile : "./frontend/Dockerfile" ,
131
+ SvcPort : "80" ,
132
+ })
133
+ Expect (err ).NotTo (HaveOccurred ())
134
+ })
135
+ It ("should generate a manifest file" , func () {
136
+ Expect (filepath .Join (repoName , "copilot" , "frontend" , "manifest.yml" )).Should (BeAnExistingFile ())
137
+ })
138
+ It ("should list the service" , func () {
139
+ out , err := copilot .SvcList (appName )
140
+ Expect (err ).NotTo (HaveOccurred ())
141
+ Expect (len (out .Services )).To (Equal (1 ))
142
+ Expect (out .Services [0 ].Name ).To (Equal ("frontend" ))
143
+ })
144
+ })
145
+
146
+ Context ("when creating the pipeline manifest" , func () {
147
+ It ("should initialize the pipeline" , func () {
148
+ _ , err := copilot .PipelineInit (appName , repoURL , "master" , []string {"test" , "prod" })
149
+ Expect (err ).NotTo (HaveOccurred ())
150
+ })
151
+ It ("should generate pipeline artifacts" , func () {
152
+ Expect (filepath .Join (repoName , "copilot" , "pipeline.yml" )).Should (BeAnExistingFile ())
153
+ Expect (filepath .Join (repoName , "copilot" , "buildspec.yml" )).Should (BeAnExistingFile ())
154
+ })
155
+ })
59
156
})
0 commit comments