Skip to content

Commit

Permalink
add more inverted config test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
parkerduckworth committed Mar 21, 2022
1 parent e87604f commit 7860f17
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions adapters/repos/db/inverted/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ func TestValidateConfig(t *testing.T) {
assert.EqualError(t, err, "BM25.b must be <= 0 and <= 1")
})

t.Run("invalid BM25.b", func(t *testing.T) {
t.Run("with valid config", func(t *testing.T) {
in := &models.InvertedIndexConfig{
CleanupIntervalSeconds: 1,
Bm25: &models.BM25Config{
K1: 1,
B: 1.001,
B: 0.1,
},
}

err := ValidateConfig(in)
assert.EqualError(t, err, "BM25.b must be <= 0 and <= 1")
assert.Nil(t, err)
})
}

Expand Down
22 changes: 22 additions & 0 deletions adapters/repos/db/inverted/config_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,26 @@ func TestValidateUserConfigUpdate(t *testing.T) {
assert.Equal(t, validInitial.Bm25.K1, updated.Bm25.K1)
assert.Equal(t, validInitial.Bm25.B, updated.Bm25.B)
})

t.Run("with invalid cleanup interval", func(t *testing.T) {
updated := &models.InvertedIndexConfig{
CleanupIntervalSeconds: -1,
}

err := ValidateUserConfigUpdate(validInitial, updated)
require.EqualError(t, err, "cleanup interval seconds must be > 0")
})

t.Run("with invalid updated Bm25 config", func(t *testing.T) {
updated := &models.InvertedIndexConfig{
CleanupIntervalSeconds: 1,
Bm25: &models.BM25Config{
K1: 1.2,
B: 1.2,
},
}

err := ValidateUserConfigUpdate(validInitial, updated)
require.EqualError(t, err, "BM25.b must be <= 0 and <= 1")
})
}

0 comments on commit 7860f17

Please sign in to comment.