Skip to content

Commit 750aa17

Browse files
authored
chore: add back file-delete test (#1694)
Adds back a test that was inappropriately removed (as explained [here](https://github.com/beeme1mr/flagd/pull/16/files#r2223712589)). Also fixes some typos. Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
1 parent c0a2940 commit 750aa17

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export GOPRIVATE=buf.build/gen/go
4242

4343
### Manual testing
4444

45-
flagd has a number of interfaces (you can read more about than at [flagd.dev](https://flagd.dev/)) which can be used to evaluate flags, or deliver flag configurations so that they can be evaluated by _in-process_ providers.
45+
flagd has a number of interfaces (you can read more about them at [flagd.dev](https://flagd.dev/)) which can be used to evaluate flags, or deliver flag configurations so that they can be evaluated by _in-process_ providers.
4646

4747
You can manually test this functionality by starting flagd (from the flagd/ directory) with `go run main.go start -f file:../config/samples/example_flags.flagd.json`.
4848

@@ -69,7 +69,7 @@ curl -X POST -d '{"context":{}}' 'http://localhost:8016/ofrep/v1/evaluate/flags
6969
grpcurl -import-path schemas/protobuf/flagd/evaluation/v1/ -proto evaluation.proto -plaintext -d '{"flagKey":"myBoolFlag"}' localhost:8013 flagd.evaluation.v1.Service/ResolveBoolean | jq
7070
```
7171

72-
#### Remote bulk evaluation via via HTTP1.1/OFREP
72+
#### Remote bulk evaluation via HTTP1.1/OFREP
7373

7474
```sh
7575
# evaluates flags in bulk
@@ -93,7 +93,7 @@ grpcurl -import-path schemas/protobuf/flagd/sync/v1/ -proto sync.proto -plaintex
9393
#### Flag synchronization stream via gRPC
9494

9595
```sh
96-
# will open a persistent stream which sends flag changes when the watched source is modified
96+
# will open a persistent stream which sends flag changes when the watched source is modified
9797
grpcurl -import-path schemas/protobuf/flagd/sync/v1/ -proto sync.proto -plaintext localhost:8015 flagd.sync.v1.FlagSyncService/SyncFlags | jq
9898
```
9999

core/pkg/sync/file/filepath_sync_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func TestSimpleReSync(t *testing.T) {
5858
func TestSimpleSync(t *testing.T) {
5959
readDirName := t.TempDir()
6060
updateDirName := t.TempDir()
61+
deleteDirName := t.TempDir()
6162
tests := map[string]struct {
6263
manipulationFuncs []func(t *testing.T)
6364
expectedDataSync []sync.DataSync
@@ -98,6 +99,27 @@ func TestSimpleSync(t *testing.T) {
9899
},
99100
},
100101
},
102+
"delete-event": {
103+
fetchDirName: deleteDirName,
104+
manipulationFuncs: []func(t *testing.T){
105+
func(t *testing.T) {
106+
writeToFile(t, deleteDirName, fetchFileContents)
107+
},
108+
func(t *testing.T) {
109+
deleteFile(t, deleteDirName, fetchFileName)
110+
},
111+
},
112+
expectedDataSync: []sync.DataSync{
113+
{
114+
FlagData: fetchFileContents,
115+
Source: fmt.Sprintf("%s/%s", deleteDirName, fetchFileName),
116+
},
117+
{
118+
FlagData: defaultState,
119+
Source: fmt.Sprintf("%s/%s", deleteDirName, fetchFileName),
120+
},
121+
},
122+
},
101123
}
102124

103125
for test, tt := range tests {

core/pkg/sync/http/http_sync_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,16 @@ func TestHTTPSync_Fetch(t *testing.T) {
290290
newETag := `"c2e01ce63d90109c4c7f4f6dcea97ed1bb2b51e3647f36caf5acbe27413a24bb"`
291291

292292
return &http.Response{
293-
Header: map[string][]string{
293+
Header: map[string][]string{
294294
"Content-Type": {"application/json"},
295-
"Etag": {newETag},
295+
"Etag": {newETag},
296296
},
297297
Body: io.NopCloser(strings.NewReader(newContent)),
298298
StatusCode: http.StatusOK,
299299
}, nil
300300
})
301301
},
302-
uri: "http://localhost",
302+
uri: "http://localhost",
303303
eTagHeader: `"1af17a664e3fa8e419b8ba05c2a173169df76162a5a286e0c405b460d478f7ef"`,
304304
handleResponse: func(t *testing.T, httpSync Sync, _ string, err error) {
305305
if err != nil {
@@ -370,7 +370,7 @@ func TestSync_Init(t *testing.T) {
370370
func TestHTTPSync_Resync(t *testing.T) {
371371
ctrl := gomock.NewController(t)
372372
source := "http://localhost"
373-
emptyeFlagData := "{}"
373+
emptyFlagData := "{}"
374374

375375
tests := map[string]struct {
376376
setup func(t *testing.T, client *syncmock.MockClient)
@@ -385,7 +385,7 @@ func TestHTTPSync_Resync(t *testing.T) {
385385
setup: func(_ *testing.T, client *syncmock.MockClient) {
386386
client.EXPECT().Do(gomock.Any()).Return(&http.Response{
387387
Header: map[string][]string{"Content-Type": {"application/json"}},
388-
Body: io.NopCloser(strings.NewReader(emptyeFlagData)),
388+
Body: io.NopCloser(strings.NewReader(emptyFlagData)),
389389
StatusCode: http.StatusOK,
390390
}, nil)
391391
},
@@ -402,7 +402,7 @@ func TestHTTPSync_Resync(t *testing.T) {
402402
wantErr: false,
403403
wantNotifications: []sync.DataSync{
404404
{
405-
FlagData: emptyeFlagData,
405+
FlagData: emptyFlagData,
406406
Source: source,
407407
},
408408
},

0 commit comments

Comments
 (0)