Semaphore/db/bolt/option_test.go

53 lines
793 B
Go
Raw Permalink Normal View History

2024-03-10 18:55:42 +01:00
package bolt
import (
"testing"
)
func TestGetOption(t *testing.T) {
store := CreateTestStore()
2024-03-10 19:00:15 +01:00
val, err := store.GetOption("unknown_option")
2024-03-10 18:55:42 +01:00
2024-03-10 19:00:15 +01:00
if err != nil && val != "" {
t.Fatal("Result must be empty string for non-existent option")
2024-03-10 18:55:42 +01:00
}
}
func TestGetSetOption(t *testing.T) {
store := CreateTestStore()
err := store.SetOption("age", "33")
if err != nil {
t.Fatal("Can not save option")
}
val, err := store.GetOption("age")
if err != nil {
t.Fatal("Can not get option")
}
if val != "33" {
t.Fatal("Invalid option value")
}
err = store.SetOption("age", "22")
if err != nil {
t.Fatal("Can not save option")
}
val, err = store.GetOption("age")
if err != nil {
t.Fatal("Can not get option")
}
if val != "22" {
t.Fatal("Invalid option value")
}
}