@@ -48,6 +48,45 @@ func TestEnvironmentServiceCreateEphemeralEnvironment(t *testing.T) {
4848 require .Equal (t , createdEnvironmentId , environments .Items [0 ].ID )
4949}
5050
51+ func TestEnvironmentServiceDeprovisionEphemeralEnvironmentForProject (t * testing.T ) {
52+ client := getOctopusClient ()
53+ require .NotNil (t , client )
54+
55+ space := GetDefaultSpace (t , client )
56+ require .NotNil (t , space )
57+
58+ lifecycle := CreateTestLifecycle (t , client )
59+ require .NotNil (t , lifecycle )
60+ defer DeleteTestLifecycle (t , client , lifecycle )
61+
62+ projectGroup := CreateTestProjectGroup (t , client )
63+ require .NotNil (t , projectGroup )
64+ defer DeleteTestProjectGroup (t , client , projectGroup )
65+
66+ project := CreateTestProject (t , client , space , lifecycle , projectGroup )
67+ require .NotNil (t , project )
68+ defer DeleteTestProject (t , client , project )
69+
70+ runbook := CreateTestRunbook (t , client , lifecycle , projectGroup , project )
71+ require .NotNil (t , runbook )
72+ defer DeleteTestRunbook (t , client , runbook )
73+
74+ parentEnvironment := CreateParentEnvironment (t , client )
75+ require .NotNil (t , parentEnvironment )
76+ defer DeleteParentEnvironment (t , client , parentEnvironment )
77+
78+ ephemeralChannel := CreateEphemeralTestChannel (t , client , project , parentEnvironment )
79+ require .NotNil (t , ephemeralChannel )
80+ defer DeleteTestChannel (t , client , ephemeralChannel )
81+
82+ createdEnvironmentId := CreateEphemeralEnvironment (t , client , project )
83+ DeprovisionEphemeralEnvironmentForProject (t , client , & createdEnvironmentId , project )
84+
85+ environments , err := ephemeralenvironments .GetAll (client , client .GetSpaceID ())
86+ require .NoError (t , err )
87+ require .NotNil (t , environments )
88+ }
89+
5190func CreateEphemeralEnvironment (t * testing.T , client * client.Client , project * projects.Project ) string {
5291 if client == nil {
5392 client = getOctopusClient ()
@@ -63,3 +102,16 @@ func CreateEphemeralEnvironment(t *testing.T, client *client.Client, project *pr
63102
64103 return createdEnvironment .Id
65104}
105+
106+ func DeprovisionEphemeralEnvironmentForProject (t * testing.T , client * client.Client , environmentId * string , project * projects.Project ) ephemeralenvironments.DeprovisioningRunbookRun {
107+ if client == nil {
108+ client = getOctopusClient ()
109+ }
110+ require .NotNil (t , client )
111+
112+ deprovisionResponse , err := ephemeralenvironments .DeprovisionForProject (client , client .GetSpaceID (), * environmentId , project .GetID ())
113+ require .NoError (t , err )
114+ require .NotNil (t , deprovisionResponse )
115+
116+ return deprovisionResponse .DeprovisioningRun
117+ }
0 commit comments