Skip to content

Commit

Permalink
Fix Linting Errors
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
  • Loading branch information
mahadzaryab1 committed Nov 11, 2024
1 parent e6d8849 commit 8c53039
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cmd/es-rollover/app/rollover/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ func TestBindFlags(t *testing.T) {
require.NoError(t, err)

c.InitFromViper(v)
assert.Equal(t, "{\"max_age\": \"20000d\"}", c.Conditions)
assert.JSONEq(t, `{"max_age": "20000d"}`, c.Conditions)
}
8 changes: 4 additions & 4 deletions cmd/ingester/app/consumer/offset/concurrent_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func insert(list *ConcurrentList, offsets ...int64) {

func TestInsert(t *testing.T) {
for _, testCase := range generatePermutations([]int64{1, 2, 3}) {
min, toInsert := extractMin(testCase)
s := newConcurrentList(min)
m, toInsert := extractMin(testCase)
s := newConcurrentList(m)
insert(s, toInsert...)
assert.ElementsMatch(t, testCase, s.offsets)
}
Expand Down Expand Up @@ -62,8 +62,8 @@ func TestGetHighestAndReset(t *testing.T) {
for _, testCase := range testCases {
for _, input := range generatePermutations(testCase.input) {
t.Run(fmt.Sprintf("%v", input), func(t *testing.T) {
min, input := extractMin(input)
s := newConcurrentList(min)
m, input := extractMin(input)
s := newConcurrentList(m)
insert(s, input...)
actualOffset := s.setToHighestContiguous()
assert.ElementsMatch(t, testCase.expectedList, s.offsets)
Expand Down
2 changes: 1 addition & 1 deletion model/spanref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestSpanRefTypeToFromJSON(t *testing.T) {
out := new(bytes.Buffer)
err := new(jsonpb.Marshaler).Marshal(out, &sr)
require.NoError(t, err)
assert.Equal(t, `{"traceId":"AAAAAAAAAAAAAAAAAAAAQg==","spanId":"AAAAAAAAAEM=","refType":"FOLLOWS_FROM"}`, out.String())
assert.JSONEq(t, `{"traceId":"AAAAAAAAAAAAAAAAAAAAQg==","spanId":"AAAAAAAAAEM=","refType":"FOLLOWS_FROM"}`, out.String())
var sr2 model.SpanRef
require.NoError(t, jsonpb.Unmarshal(out, &sr2))
assert.Equal(t, sr, sr2)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Cache interface {

// CompareAndSwap adds an element to the cache if the existing entry matches the old value.
// It returns the element in cache after function is executed and true if the element was replaced, false otherwise.
CompareAndSwap(key string, old, new any) (any, bool)
CompareAndSwap(key string, oldEntry, newEntry any) (any, bool)
}

// Options control the behavior of the cache
Expand Down
7 changes: 0 additions & 7 deletions pkg/discovery/grpcresolver/grpc_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,6 @@ func (r *Resolver) rendezvousHash(addresses []string) []string {
return topN
}

func min(a, b int) int {
if a < b {
return a
}
return b
}

func hashAddr(hasher hash.Hash32, node, saltKey []byte) uint32 {
hasher.Reset()
hasher.Write(saltKey)
Expand Down
2 changes: 1 addition & 1 deletion pkg/testutils/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestNewLogger(t *testing.T) {
logger, log := NewLogger()
logger.Warn("hello", zap.String("x", "y"))

assert.Equal(t, `{"level":"warn","msg":"hello","x":"y"}`, log.Lines()[0])
assert.JSONEq(t, `{"level":"warn","msg":"hello","x":"y"}`, log.Lines()[0])
assert.Equal(t, map[string]string{
"level": "warn",
"msg": "hello",
Expand Down
4 changes: 2 additions & 2 deletions pkg/version/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestRegisterHandler(t *testing.T) {
commitSHA = "foobar"
latestVersion = "v1.2.3"
date = "2024-01-04"
expectedJSON := []byte(`{"gitCommit":"foobar","gitVersion":"v1.2.3","buildDate":"2024-01-04"}`)
expectedJSON := `{"gitCommit":"foobar","gitVersion":"v1.2.3","buildDate":"2024-01-04"}`

mockLogger := zap.NewNop()
mux := http.NewServeMux()
Expand All @@ -33,5 +33,5 @@ func TestRegisterHandler(t *testing.T) {
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
resp.Body.Close()
assert.Equal(t, expectedJSON, body)
assert.JSONEq(t, expectedJSON, string(body))
}
4 changes: 2 additions & 2 deletions plugin/sampling/strategyprovider/static/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func TestServiceNoPerOperationStrategies(t *testing.T) {
expectedServiceResponse, err := os.ReadFile(snapshotFile)
require.NoError(t, err)

assert.Equal(t, string(expectedServiceResponse), string(strategyJson),
assert.JSONEq(t, string(expectedServiceResponse), string(strategyJson),
"comparing against stored snapshot. Use REGENERATE_SNAPSHOTS=true to rebuild snapshots.")

if regenerateSnapshots {
Expand Down Expand Up @@ -527,7 +527,7 @@ func TestServiceNoPerOperationStrategiesDeprecatedBehavior(t *testing.T) {
expectedServiceResponse, err := os.ReadFile(snapshotFile)
require.NoError(t, err)

assert.Equal(t, string(expectedServiceResponse), string(strategyJson),
assert.JSONEq(t, string(expectedServiceResponse), string(strategyJson),
"comparing against stored snapshot. Use REGENERATE_SNAPSHOTS=true to rebuild snapshots.")

if regenerateSnapshots {
Expand Down

0 comments on commit 8c53039

Please sign in to comment.