oficina / base Public

Clone
git clone https://amadan.net/oficina/base

Plain git — no account needed to clone.

Download

Download this file

1package store
2
3import (
4 "context"
5 "testing"
6)
7
8// A member's Appearance starts as the device's ("") and holds what they
9// choose, on every device: it is on their member row.
10func TestTheme(t *testing.T) {
11 ctx, db := context.Background(), open(t)
12 if err := Bootstrap(ctx, db, "owner@example.com"); err != nil {
13 t.Fatal(err)
14 }
15 theme := func() string {
16 t.Helper()
17 m, _, err := MemberByEmail(ctx, db, "owner@example.com")
18 if err != nil {
19 t.Fatal(err)
20 }
21 return m.Theme
22 }
23 if got := theme(); got != "" {
24 t.Fatalf("fresh member: %q, want the device's", got)
25 }
26 owner, _, _ := MemberByEmail(ctx, db, "owner@example.com")
27 for _, want := range []string{"light", "dark", ""} {
28 if err := SetTheme(ctx, db, owner.ID, want); err != nil {
29 t.Fatal(err)
30 }
31 if got := theme(); got != want {
32 t.Errorf("after choosing %q: %q", want, got)
33 }
34 }
35 if err := SetTheme(ctx, db, "no-such-member", "light"); err == nil {
36 t.Error("set for a member who isn't there")
37 }
38}
39