Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
fix/tests: after pr #35 tests were broken, fix it with few error and …
Browse files Browse the repository at this point in the history
…ignore tmp files changes
  • Loading branch information
Maksim Konovalov committed Aug 26, 2024
1 parent ef71933 commit 1bf4c27
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
*.pid

# Go output
*.out
*.out

# Tmp
*.tmp
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ REFACTOR:

* Refactored docs (add QuickStart doc) and that library base on vhsard router
* Several linters are enabled because they are usefull
* Ignore .tmp files



Expand Down
2 changes: 1 addition & 1 deletion replicaset.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (rs *Replicaset) BucketStat(ctx context.Context, bucketID uint64) (BucketSt
}

if len(respData) < 1 {
return bsInfo, fmt.Errorf("respData len is 0 for %s", bucketStatFnc)
return bsInfo, fmt.Errorf("respData len is 0 for %s; unsupported or broken proto", bucketStatFnc)
}

if respData[0] == nil {
Expand Down
37 changes: 21 additions & 16 deletions replicaset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,9 @@ func TestReplicaset_BucketStat(t *testing.T) {
require.Equal(t, futureError, err)
})

t.Run("wrong bucket", func(t *testing.T) {
t.Run("unsupported or broken proto resp", func(t *testing.T) {
f := tarantool.NewFuture(tarantool.NewCallRequest("vshard.storage.bucket_stat"))
/*
unix/:./data/storage_1_a.control> vshard.storage.bucket_stat(1000)
---
- null
- bucket_id: 1000
reason: Not found
code: 1
type: ShardingError
message: 'Cannot perform action with bucket 1000, reason: Not found'
name: WRONG_BUCKET
...
*/

bts, _ := msgpack.Marshal([]interface{}{1})

err := f.SetResponse(tarantool.Header{}, bytes.NewReader(bts))
Expand All @@ -81,8 +70,24 @@ func TestReplicaset_BucketStat(t *testing.T) {
rs.conn = mPool

// todo: add real tests
require.Panics(t, func() {
_, err = rs.BucketStat(ctx, 123)
})

statInfo, err := rs.BucketStat(ctx, 123)
require.Error(t, err)
require.Equal(t, statInfo, BucketStatInfo{BucketID: 0, Status: ""})
})

/*
TODO: add test for wrong bucket response
unix/:./data/storage_1_a.control> vshard.storage.bucket_stat(1000)
---
- null
- bucket_id: 1000
reason: Not found
code: 1
type: ShardingError
message: 'Cannot perform action with bucket 1000, reason: Not found'
name: WRONG_BUCKET
...
*/
}

0 comments on commit 1bf4c27

Please sign in to comment.