Skip to content

Commit

Permalink
chore: fix error about invalid offset with FS backend (#2286)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Phelps <[email protected]>
  • Loading branch information
yquansah and markphelps committed Oct 26, 2023
1 parent 8623a43 commit 302fe8c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Empty file.
4 changes: 4 additions & 0 deletions internal/storage/fs/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,10 @@ func find[T any](match func(T) bool, ts ...T) (t T, _ bool) {
}

func paginate[T any](params storage.QueryParams, less func(i, j int) bool, items ...T) (storage.ResultSet[T], error) {
if len(items) == 0 {
return storage.ResultSet[T]{}, nil
}

set := storage.ResultSet[T]{
Results: items,
}
Expand Down
18 changes: 18 additions & 0 deletions internal/storage/fs/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,24 @@ func TestFS_Invalid_BooleanFlag_Segment(t *testing.T) {
require.EqualError(t, err, "flag fruit/apple rule 1 references unknown segment \"unknown\"")
}

func TestFS_Empty_Features_File(t *testing.T) {
fs, _ := fs.Sub(testdata, "fixtures/empty_features")
ss, err := SnapshotFromFS(zaptest.NewLogger(t), fs)
require.NoError(t, err)

_, err = ss.ListFlags(context.TODO(), flipt.DefaultNamespace)
require.NoError(t, err)

_, err = ss.ListSegments(context.TODO(), flipt.DefaultNamespace)
require.NoError(t, err)

_, err = ss.ListRollouts(context.TODO(), flipt.DefaultNamespace, "no-flag")
require.NoError(t, err)

_, err = ss.ListRules(context.TODO(), flipt.DefaultNamespace, "no-flag")
require.NoError(t, err)
}

func TestFS_YAML_Stream(t *testing.T) {
fs, _ := fs.Sub(testdata, "fixtures/yaml_stream")
ss, err := SnapshotFromFS(zaptest.NewLogger(t), fs)
Expand Down

0 comments on commit 302fe8c

Please sign in to comment.