|
1 | 1 | package home |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "path/filepath" |
5 | 4 | "testing" |
6 | 5 |
|
7 | 6 | "github.com/spf13/cobra" |
8 | | - |
9 | | - "github.com/cocoonstack/cocoon/images" |
10 | | - "github.com/cocoonstack/cocoon/images/cloudimg" |
11 | | - metajson "github.com/cocoonstack/cocoon/meta/json" |
12 | | - "github.com/cocoonstack/cocoon/meta/tombstone" |
13 | 7 | ) |
14 | 8 |
|
15 | | -// TestCloudimgNamespace pins the namespace to cocoon's layout: a drifting key |
16 | | -// or path would leave cocoon-written state unreadable here. |
17 | | -func TestCloudimgNamespace(t *testing.T) { |
18 | | - root := t.TempDir() |
19 | | - ns := cloudimgNamespace(root) |
20 | | - conf := cloudimg.NewConfig(root, 0) |
21 | | - |
22 | | - if ns.Name != cloudimg.NamespaceName { |
23 | | - t.Errorf("name = %q, want %q", ns.Name, cloudimg.NamespaceName) |
24 | | - } |
25 | | - if ns.FilePath != conf.IndexFile() { |
26 | | - t.Errorf("file = %q, want %q", ns.FilePath, conf.IndexFile()) |
27 | | - } |
28 | | - if ns.LockPath != conf.IndexLock() { |
29 | | - t.Errorf("lock = %q, want %q", ns.LockPath, conf.IndexLock()) |
30 | | - } |
31 | | - if got, want := filepath.Dir(ns.FilePath), filepath.Dir(ns.LockPath); got != want { |
32 | | - t.Errorf("file dir %q != lock dir %q", got, want) |
33 | | - } |
34 | | - |
35 | | - codec, ok := ns.Codec.(metajson.TableCodec) |
36 | | - if !ok { |
37 | | - t.Fatalf("codec type = %T, want metajson.TableCodec", ns.Codec) |
38 | | - } |
39 | | - want := []metajson.TableSpec{ |
40 | | - {Key: "images", Table: images.TableRecords}, |
41 | | - {Key: "tombstones", Table: tombstone.TableName, Optional: true}, |
42 | | - } |
43 | | - if len(codec.Specs) != len(want) { |
44 | | - t.Fatalf("specs = %v, want %v", codec.Specs, want) |
45 | | - } |
46 | | - for i, w := range want { |
47 | | - if codec.Specs[i] != w { |
48 | | - t.Errorf("spec[%d] = %+v, want %+v", i, codec.Specs[i], w) |
49 | | - } |
50 | | - } |
51 | | -} |
52 | | - |
53 | 9 | // TestOpenStoreEmpty covers the full OpenStore path on a fresh state dir. |
54 | 10 | func TestOpenStoreEmpty(t *testing.T) { |
55 | 11 | cmd := newTestCmd(t) |
|
0 commit comments