GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — locks/nil_store_test.go at master · asciimoth/locks Expand file tree/ Copy pathnil_store_test.goMore file actions 75 lines (69 loc) · 2.36 KB / Copy pathnil_store_test.goFile metadata and controls75 lines (69 loc) · 2.36 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 package locks import ( "context" "net/http" "net/http/httptest" "testing" ) func TestNilStoreReceivers(t *testing.T) { ctx := context.Background() var memory *Memory var local *Local var remote *HTTPStore var client *Client for name, store := range map[string]Store{"memory": memory, "local": local, "http": remote} { t.Run(name, func(t *testing.T) { _, err := store.Get(ctx, abc) requireErr(t, err, ErrFormat) _, err = store.Put(ctx, abc, "value", Create) requireErr(t, err, ErrFormat) }) } for _, store := range []BatchStore{local, remote} { _, err := store.GetBatch(ctx, []ID{abc}) requireErr(t, err, ErrFormat) _, err = store.PutBatch(ctx, []Write{{ID: abc, Value: "value", Mode: Create}}) requireErr(t, err, ErrFormat) } requireErr(t, local.Validate(ctx), ErrFormat) requireErr(t, local.Recover(ctx), ErrFormat) for _, report := range []Report{ client.Get(ctx, "key"), client.GetWithPolicy(ctx, "key", First), client.Put(ctx, "key", "value", Create), client.PutWithPolicy(ctx, "key", "value", Create, WriteFirst), client.Create(ctx, "key", "value"), client.Replace(ctx, "key", "value"), } { requireErr(t, report.Err, ErrFormat) } if client.Locations() != nil || client.Chain() != nil { t.Fatal("nil client has configuration") } } func TestUninitializedHTTPStore(t *testing.T) { var store HTTPStore _, err := store.Get(context.Background(), abc) requireErr(t, err, ErrFormat) } func TestUninitializedLocalStore(t *testing.T) { var store Local ctx := context.Background() _, err := store.Get(ctx, abc) requireErr(t, err, ErrFormat) _, err = store.Put(ctx, abc, "value", Create) requireErr(t, err, ErrFormat) _, err = store.GetBatch(ctx, []ID{abc}) requireErr(t, err, ErrFormat) _, err = store.PutBatch(ctx, []Write{{ID: abc, Value: "value", Mode: Create}}) requireErr(t, err, ErrFormat) requireErr(t, store.Validate(ctx), ErrFormat) requireErr(t, store.Recover(ctx), ErrFormat) } func TestUninitializedHandler(t *testing.T) { request := httptest.NewRequest(http.MethodGet, "/lock?key=id."+string(abc), nil) for _, handler := range []*Handler{nil, {}} { response := httptest.NewRecorder() handler.ServeHTTP(response, request) if response.Code != http.StatusInternalServerError || response.Body.String() != errorBody("unavailable", 0) { t.Fatalf("uninitialized handler: HTTP %d %q", response.Code, response.Body.String()) } } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |