@@ -2,13 +2,14 @@ package static_test
22
33import (
44 "encoding/json"
5- "github.com/sirupsen/logrus/hooks/test"
6- "github.com/stretchr/testify/require"
75 "mokapi/config/decoders"
86 "mokapi/config/dynamic/provider/file/filetest"
97 "mokapi/config/static"
108 "os"
119 "testing"
10+
11+ "github.com/sirupsen/logrus/hooks/test"
12+ "github.com/stretchr/testify/require"
1213)
1314
1415func TestStaticConfig (t * testing.T ) {
@@ -179,6 +180,21 @@ func TestStaticConfig(t *testing.T) {
179180 require .Equal (t , "3m" , cfg .Providers .Git .Repositories [0 ].PullInterval )
180181 },
181182 },
183+ {
184+ name : "api port as env var" ,
185+ test : func (t * testing.T ) {
186+ os .Args = append (os .Args , "mokapi.exe" )
187+ err := os .Setenv ("MOKAPI_API_PORT" , "1234" )
188+ require .NoError (t , err )
189+ defer os .Unsetenv ("MOKAPI_API_PORT" )
190+
191+ cfg := static.Config {}
192+ err = decoders .Load ([]decoders.ConfigDecoder {& decoders.FlagDecoder {}}, & cfg )
193+ require .NoError (t , err )
194+
195+ require .Equal (t , 1234 , cfg .Api .Port )
196+ },
197+ },
182198 {
183199 name : "file provider include" ,
184200 test : func (t * testing.T ) {
0 commit comments