(t *testing.T)
| 77 | } |
| 78 | |
| 79 | func TestCreate(t *testing.T) { |
| 80 | initDb(t) |
| 81 | defer cleanupDb(t) |
| 82 | |
| 83 | ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second) |
| 84 | defer cancelFn() |
| 85 | zoneId := uuid.NewString() |
| 86 | err := WFS.MakeFile(ctx, zoneId, "testfile", nil, wshrpc.FileOpts{}) |
| 87 | if err != nil { |
| 88 | t.Fatalf("error creating file: %v", err) |
| 89 | } |
| 90 | file, err := WFS.Stat(ctx, zoneId, "testfile") |
| 91 | if err != nil { |
| 92 | t.Fatalf("error stating file: %v", err) |
| 93 | } |
| 94 | if file == nil { |
| 95 | t.Fatalf("file not found") |
| 96 | } |
| 97 | if file.ZoneId != zoneId { |
| 98 | t.Fatalf("zone id mismatch") |
| 99 | } |
| 100 | if file.Name != "testfile" { |
| 101 | t.Fatalf("name mismatch") |
| 102 | } |
| 103 | if file.Size != 0 { |
| 104 | t.Fatalf("size mismatch") |
| 105 | } |
| 106 | if file.CreatedTs == 0 { |
| 107 | t.Fatalf("created ts zero") |
| 108 | } |
| 109 | if file.ModTs == 0 { |
| 110 | t.Fatalf("mod ts zero") |
| 111 | } |
| 112 | if file.CreatedTs != file.ModTs { |
| 113 | t.Fatalf("create ts != mod ts") |
| 114 | } |
| 115 | if len(file.Meta) != 0 { |
| 116 | t.Fatalf("meta should have no values") |
| 117 | } |
| 118 | if file.Opts.Circular || file.Opts.IJson || file.Opts.MaxSize != 0 { |
| 119 | t.Fatalf("opts not empty") |
| 120 | } |
| 121 | zoneIds, err := WFS.GetAllZoneIds(ctx) |
| 122 | if err != nil { |
| 123 | t.Fatalf("error getting zone ids: %v", err) |
| 124 | } |
| 125 | if len(zoneIds) != 1 { |
| 126 | t.Fatalf("zone id count mismatch") |
| 127 | } |
| 128 | if zoneIds[0] != zoneId { |
| 129 | t.Fatalf("zone id mismatch") |
| 130 | } |
| 131 | err = WFS.DeleteFile(ctx, zoneId, "testfile") |
| 132 | if err != nil { |
| 133 | t.Fatalf("error deleting file: %v", err) |
| 134 | } |
| 135 | zoneIds, err = WFS.GetAllZoneIds(ctx) |
| 136 | if err != nil { |
nothing calls this directly
no test coverage detected