40 lines
799 B
Go
40 lines
799 B
Go
|
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)
|
||
|
}
|
||
|
}
|