mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-15 07:18:04 +00:00
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
```
42 lines
842 B
Go
42 lines
842 B
Go
package server_test
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/molecula/featurebase/v2/server"
|
|
"github.com/molecula/featurebase/v2/toml"
|
|
)
|
|
|
|
func Test_ValidateConfig(t *testing.T) {
|
|
c := server.NewConfig()
|
|
c.MustValidate()
|
|
}
|
|
|
|
func TestDuration(t *testing.T) {
|
|
d := toml.Duration(time.Second * 182)
|
|
if d.String() != "3m2s" {
|
|
t.Fatalf("Unexpected time Duration %s", d)
|
|
}
|
|
|
|
b := []byte{51, 109, 50, 115}
|
|
v, _ := d.MarshalText()
|
|
if !reflect.DeepEqual(b, v) {
|
|
t.Fatalf("Unexpected marshalled value %v", v)
|
|
}
|
|
|
|
v, _ = d.MarshalTOML()
|
|
if !reflect.DeepEqual(b, v) {
|
|
t.Fatalf("Unexpected marshalled value %v", v)
|
|
}
|
|
|
|
err := d.UnmarshalText([]byte("3m2s"))
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
v, _ = d.MarshalText()
|
|
if !reflect.DeepEqual(b, v) {
|
|
t.Fatalf("Unexpected marshalled value %v", v)
|
|
}
|
|
}
|