Skip to content

Commit

Permalink
minor suggested changes
Browse files Browse the repository at this point in the history
Signed-off-by: slayer321 <[email protected]>
  • Loading branch information
slayer321 committed Oct 17, 2023
1 parent 057ba07 commit ba1e613
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugin/storage/badger/samplingstore/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func decodeThroughtputValue(val []byte) ([]*model.Throughput, error) {
if err != nil {
return nil, err
}
return throughput, nil
return throughput, err
}

func decodeProbabilitiesValue(val []byte) (ProbabilitiesAndQPS, error) {
Expand Down
10 changes: 7 additions & 3 deletions plugin/storage/badger/samplingstore/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,15 @@ func TestDecodeProbabilitiesValue(t *testing.T) {

marshalBytes, err := json.Marshal(expected)
assert.NoError(t, err)
// This should pass without error
actual, err := decodeProbabilitiesValue(marshalBytes)
assert.NoError(t, err)
assert.Equal(t, expected, actual)

// Simulate data corruption by removing the first byte.
corruptedBytes := marshalBytes[1:]
_, err = decodeProbabilitiesValue(corruptedBytes)
assert.Error(t, err) // Expect an error
}

func TestDecodeThroughtputValue(t *testing.T) {
Expand All @@ -125,12 +131,10 @@ func runWithBadger(t *testing.T, test func(t *testing.T, store *SamplingStore))
opts.ValueDir = dir

store, err := badger.Open(opts)
assert.NoError(t, err)
defer func() {
assert.NoError(t, store.Close())
}()
ss := newTestSamplingStore(store)

assert.NoError(t, err)

test(t, ss)
}

0 comments on commit ba1e613

Please sign in to comment.