featurebase/client/record_test.go
reesporte 4c53f86e82 removed license from each go file
i used this script, a little clunky but it got the job done

```bash
for file in `find . -type f -print | grep '\.go'`; do
    sed '1,/^\/\/ limitations under the License.$/d' $file > $file.tmp;
    result=`cat $file.tmp`
    if [[ result != "" ]]; then
        gofmt $file.tmp &> /dev/null;
        if [[ $? == 0 ]]; then
            mv $file.tmp $file && gofmt -w $file;
        else
            rm $file.tmp;
        fi
    else
        rm $file.tmp;
    fi
done
```
2021-12-10 09:17:17 -06:00

69 lines
1.7 KiB
Go

// package ctl contains all pilosa subcommands other than 'server'. These are
// generally administration, testing, and debugging tools.
package client_test
import (
"testing"
"github.com/molecula/featurebase/v2/client"
)
func TestColumnShard(t *testing.T) {
a := client.Column{RowID: 15, ColumnID: 55, Timestamp: 100101}
target := uint64(0)
if a.Shard(100) != target {
t.Fatalf("shard %d != %d", target, a.Shard(100))
}
target = 5
if a.Shard(10) != target {
t.Fatalf("shard %d != %d", target, a.Shard(10))
}
}
func TestColumnLess(t *testing.T) {
a := client.Column{RowID: 10, ColumnID: 200}
a2 := client.Column{RowID: 10, ColumnID: 1000}
b := client.Column{RowID: 200, ColumnID: 10}
c := client.FieldValue{ColumnID: 1}
if !a.Less(a2) {
t.Fatalf("%v should be less than %v", a, a2)
}
if !a.Less(b) {
t.Fatalf("%v should be less than %v", a, b)
}
if b.Less(a) {
t.Fatalf("%v should not be less than %v", b, a)
}
if c.Less(a) {
t.Fatalf("%v should not be less than %v", c, a)
}
}
func TestFieldValueShard(t *testing.T) {
a := client.FieldValue{ColumnID: 55, Value: 125}
target := uint64(0)
if a.Shard(100) != target {
t.Fatalf("shard %d != %d", target, a.Shard(100))
}
target = 5
if a.Shard(10) != target {
t.Fatalf("shard %d != %d", target, a.Shard(10))
}
}
func TestFieldValueLess(t *testing.T) {
a := client.FieldValue{ColumnID: 55, Value: 125}
b := client.FieldValue{ColumnID: 100, Value: 125}
c := client.Column{ColumnID: 1, RowID: 2}
if !a.Less(b) {
t.Fatalf("%v should be less than %v", a, b)
}
if b.Less(a) {
t.Fatalf("%v should not be less than %v", b, a)
}
if c.Less(a) {
t.Fatalf("%v should not be less than %v", c, a)
}
}