@@ -22,6 +22,61 @@ import (
2222 "github.com/stretchr/testify/assert"
2323)
2424
25+ func Test_DotEnv_SetAppEnvManifestVariables (t * testing.T ) {
26+ tests := map [string ]struct {
27+ teamDomain string
28+ isDev bool
29+ initialEnv map [string ]string
30+ expected map [string ]string
31+ }{
32+ "sets built-in vars for deployed app" : {
33+ teamDomain : "bigspeck" ,
34+ isDev : false ,
35+ expected : map [string ]string {
36+ "SLACK_WORKSPACE" : "bigspeck" ,
37+ "SLACK_ENV" : "deployed" ,
38+ },
39+ },
40+ "sets built-in vars for local app" : {
41+ teamDomain : "sandbox" ,
42+ isDev : true ,
43+ expected : map [string ]string {
44+ "SLACK_WORKSPACE" : "sandbox" ,
45+ "SLACK_ENV" : "local" ,
46+ },
47+ },
48+ "handles nil ManifestEnv" : {
49+ teamDomain : "team" ,
50+ isDev : true ,
51+ initialEnv : nil ,
52+ expected : map [string ]string {
53+ "SLACK_WORKSPACE" : "team" ,
54+ "SLACK_ENV" : "local" ,
55+ },
56+ },
57+ "preserves existing ManifestEnv values" : {
58+ teamDomain : "team" ,
59+ isDev : false ,
60+ initialEnv : map [string ]string {"SLACK_APP_ID" : "A1234" },
61+ expected : map [string ]string {
62+ "SLACK_APP_ID" : "A1234" ,
63+ "SLACK_WORKSPACE" : "team" ,
64+ "SLACK_ENV" : "deployed" ,
65+ },
66+ },
67+ }
68+ for name , tc := range tests {
69+ t .Run (name , func (t * testing.T ) {
70+ fs := slackdeps .NewFsMock ()
71+ os := slackdeps .NewOsMock ()
72+ config := NewConfig (fs , os )
73+ config .ManifestEnv = tc .initialEnv
74+ config .SetAppEnvManifestVariables (tc .teamDomain , tc .isDev )
75+ assert .Equal (t , tc .expected , config .ManifestEnv )
76+ })
77+ }
78+ }
79+
2580func Test_DotEnv_GetDotEnvFileVariables (t * testing.T ) {
2681 tests := map [string ]struct {
2782 globalVariableName string
0 commit comments