-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathdb_test.go
More file actions
39 lines (33 loc) · 783 Bytes
/
db_test.go
File metadata and controls
39 lines (33 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package cmd
import (
"testing"
"github.com/tursodatabase/turso-cli/internal/turso"
)
func TestSuggestDatabaseNameFromHostnamePrefix(t *testing.T) {
databases := []turso.Database{
{
Name: "hello",
Hostname: "hello-penberg.turso.io",
},
{
Name: "other",
Hostname: "other-penberg.turso.io",
},
}
got := suggestDatabaseName("hello-penberg", databases)
if got != "hello" {
t.Fatalf("suggestDatabaseName() = %q, want %q", got, "hello")
}
}
func TestSuggestDatabaseNameIgnoresUnmatchedName(t *testing.T) {
databases := []turso.Database{
{
Name: "hello",
Hostname: "hello-penberg.turso.io",
},
}
got := suggestDatabaseName("missing", databases)
if got != "" {
t.Fatalf("suggestDatabaseName() = %q, want empty string", got)
}
}