TheMathemagicians/sevenkeys/cli/storage_test.go

40 lines
799 B
Go
Raw Normal View History

2024-08-20 14:28:49 +00:00
package cli
import (
"bytes"
"sevenkeys/database"
"testing"
)
func Test_showStorageInfo_DisplaysNone_IfSelectedStorageAreaIsUnset(t *testing.T) {
expected := "Selected Storage Area: [None]\n"
var output bytes.Buffer
var area database.StorageArea
showStorageInfo(&output, area)
result := output.String()
if result != expected {
t.Errorf("expected %s, got %s", expected, result)
}
}
func Test_showStorageInfo_DisplaysStorageAreaNameAndType_IfSelectedStorageAreaIsSet(t *testing.T) {
expected := "Selected Storage Area: Test A (Box)\n"
var output bytes.Buffer
area := database.StorageArea{
Id: 1,
Name: "Test A",
Type: "Box",
}
showStorageInfo(&output, area)
result := output.String()
if result != expected {
t.Errorf("expected %s, got %s", expected, result)
}
}