|
1 | 1 | package flagd |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "os" |
5 | 4 | "testing" |
6 | | - |
7 | | - "github.com/go-logr/logr" |
8 | 5 | ) |
9 | 6 |
|
10 | 7 | func TestConfigureProviderConfigurationInProcessWithOfflineFile(t *testing.T) { |
@@ -67,100 +64,3 @@ func TestValidateProviderConfigurationFileMissingData(t *testing.T) { |
67 | 64 | t.Errorf("Error expected but check succeeded") |
68 | 65 | } |
69 | 66 | } |
70 | | - |
71 | | -func TestUpdatePortFromEnvVarInProcessWithSyncPort(t *testing.T) { |
72 | | - // given |
73 | | - os.Setenv("FLAGD_SYNC_PORT", "9999") |
74 | | - defer os.Unsetenv("FLAGD_SYNC_PORT") |
75 | | - |
76 | | - providerConfiguration := &ProviderConfiguration{ |
77 | | - Resolver: inProcess, |
78 | | - log: logr.Discard(), |
79 | | - } |
80 | | - |
81 | | - // when |
82 | | - providerConfiguration.updatePortFromEnvVar() |
83 | | - |
84 | | - // then |
85 | | - if providerConfiguration.Port != 9999 { |
86 | | - t.Errorf("incorrect Port, expected %v, got %v", 9999, providerConfiguration.Port) |
87 | | - } |
88 | | -} |
89 | | - |
90 | | -func TestUpdatePortFromEnvVarInProcessWithLegacyPort(t *testing.T) { |
91 | | - // given - for backwards compatibility, FLAGD_PORT should work for in-process |
92 | | - os.Setenv("FLAGD_PORT", "8888") |
93 | | - defer os.Unsetenv("FLAGD_PORT") |
94 | | - |
95 | | - providerConfiguration := &ProviderConfiguration{ |
96 | | - Resolver: inProcess, |
97 | | - log: logr.Discard(), |
98 | | - } |
99 | | - |
100 | | - // when |
101 | | - providerConfiguration.updatePortFromEnvVar() |
102 | | - |
103 | | - // then |
104 | | - if providerConfiguration.Port != 8888 { |
105 | | - t.Errorf("incorrect Port, expected %v, got %v", 8888, providerConfiguration.Port) |
106 | | - } |
107 | | -} |
108 | | - |
109 | | -func TestUpdatePortFromEnvVarInProcessSyncPortPriority(t *testing.T) { |
110 | | - // given - FLAGD_SYNC_PORT takes priority over FLAGD_PORT |
111 | | - os.Setenv("FLAGD_SYNC_PORT", "9999") |
112 | | - os.Setenv("FLAGD_PORT", "8888") |
113 | | - defer os.Unsetenv("FLAGD_SYNC_PORT") |
114 | | - defer os.Unsetenv("FLAGD_PORT") |
115 | | - |
116 | | - providerConfiguration := &ProviderConfiguration{ |
117 | | - Resolver: inProcess, |
118 | | - log: logr.Discard(), |
119 | | - } |
120 | | - |
121 | | - // when |
122 | | - providerConfiguration.updatePortFromEnvVar() |
123 | | - |
124 | | - // then |
125 | | - if providerConfiguration.Port != 9999 { |
126 | | - t.Errorf("incorrect Port, expected %v, got %v", 9999, providerConfiguration.Port) |
127 | | - } |
128 | | -} |
129 | | - |
130 | | -func TestUpdatePortFromEnvVarRpcWithPort(t *testing.T) { |
131 | | - // given - RPC resolver uses FLAGD_PORT |
132 | | - os.Setenv("FLAGD_PORT", "8888") |
133 | | - defer os.Unsetenv("FLAGD_PORT") |
134 | | - |
135 | | - providerConfiguration := &ProviderConfiguration{ |
136 | | - Resolver: rpc, |
137 | | - log: logr.Discard(), |
138 | | - } |
139 | | - |
140 | | - // when |
141 | | - providerConfiguration.updatePortFromEnvVar() |
142 | | - |
143 | | - // then |
144 | | - if providerConfiguration.Port != 8888 { |
145 | | - t.Errorf("incorrect Port, expected %v, got %v", 8888, providerConfiguration.Port) |
146 | | - } |
147 | | -} |
148 | | - |
149 | | -func TestUpdatePortFromEnvVarRpcIgnoresSyncPort(t *testing.T) { |
150 | | - // given - RPC resolver should NOT use FLAGD_SYNC_PORT |
151 | | - os.Setenv("FLAGD_SYNC_PORT", "9999") |
152 | | - defer os.Unsetenv("FLAGD_SYNC_PORT") |
153 | | - |
154 | | - providerConfiguration := &ProviderConfiguration{ |
155 | | - Resolver: rpc, |
156 | | - log: logr.Discard(), |
157 | | - } |
158 | | - |
159 | | - // when |
160 | | - providerConfiguration.updatePortFromEnvVar() |
161 | | - |
162 | | - // then - port should remain 0 (unset) since FLAGD_PORT is not set |
163 | | - if providerConfiguration.Port != 0 { |
164 | | - t.Errorf("incorrect Port, expected %v, got %v", 0, providerConfiguration.Port) |
165 | | - } |
166 | | -} |
0 commit comments