Download this file
| 1 | package release |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "encoding/json" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestSidecarWakeCarriesExactIdentity(t *testing.T) { |
| 10 | ctx := context.Background() |
| 11 | s := NewDirStore(t.TempDir()) |
| 12 | id := SidecarWakeIdentity{AppID: "app-id", Incarnation: "old-incarnation", RequestID: "wake-request"} |
| 13 | if err := TouchSidecarWake(ctx, s, "acct", "app", "bot", "operator", "wake", id); err != nil { |
| 14 | t.Fatal(err) |
| 15 | } |
| 16 | raw, _, err := s.Get(ctx, SidecarWakeKey("acct", "app", "bot")) |
| 17 | if err != nil { |
| 18 | t.Fatal(err) |
| 19 | } |
| 20 | var got SidecarWake |
| 21 | if err = json.Unmarshal(raw, &got); err != nil { |
| 22 | t.Fatal(err) |
| 23 | } |
| 24 | if got.AppID != id.AppID || got.Incarnation != id.Incarnation || got.RequestID != id.RequestID { |
| 25 | t.Fatalf("identity lost: %+v", got) |
| 26 | } |
| 27 | if err = TouchSidecarWake(ctx, s, "acct", "app", "bot", "operator", "wake", SidecarWakeIdentity{AppID: "incomplete"}); err == nil { |
| 28 | t.Fatal("accepted partial identity") |
| 29 | } |
| 30 | } |
| 31 | |