carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package activator
2
3import (
4 "context"
5 "testing"
6)
7
8func TestBuildStateLocationRidesTheContext(t *testing.T) {
9 ctx := context.Background()
10 if l, ok := BuildStateLocationFrom(ctx); ok {
11 t.Fatalf("a bare context carries %+v", l)
12 }
13 want := BuildStateLocation{Bucket: "data-eu", Prefix: "instances/a.example.com/inc1"}
14 got, ok := BuildStateLocationFrom(WithBuildStateLocation(ctx, want))
15 if !ok || got != want {
16 t.Fatalf("got %+v, %v; want %+v", got, ok, want)
17 }
18}
19
20// A zero location is no location: it is how a caller that serves many
21// hosts (the agent's refreshAll) masks one a wake left on its context.
22func TestAnEmptyBuildStateLocationIsNone(t *testing.T) {
23 ctx := WithBuildStateLocation(context.Background(), BuildStateLocation{Bucket: "b", Prefix: "p"})
24 for _, l := range []BuildStateLocation{{}, {Bucket: "b"}, {Prefix: "p"}} {
25 if got, ok := BuildStateLocationFrom(WithBuildStateLocation(ctx, l)); ok {
26 t.Fatalf("%+v read back as %+v", l, got)
27 }
28 }
29}
30