|
| 1 | +/* |
| 2 | +Copyright 2026 Cozystack contributors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package rest |
| 18 | + |
| 19 | +import ( |
| 20 | + "net/http" |
| 21 | + "strings" |
| 22 | + "testing" |
| 23 | + |
| 24 | + "github.com/cozystack/blockstor/pkg/store" |
| 25 | +) |
| 26 | + |
| 27 | +// TestSnapshotMultiReturns501 pins the multi-RD snapshot endpoint as |
| 28 | +// explicitly out-of-scope. golinstor expects a deterministic |
| 29 | +// non-success here; falling through to 404 (the previous behaviour) |
| 30 | +// is harder to distinguish from an unknown-route bug. |
| 31 | +func TestSnapshotMultiReturns501(t *testing.T) { |
| 32 | + base, stop := startServerWithStore(t, store.NewInMemory()) |
| 33 | + defer stop() |
| 34 | + |
| 35 | + resp := httpPost(t, base+"/v1/actions/snapshot/multi", |
| 36 | + []byte(`{"resource_definitions":["pvc-1"],"snapshot_name":"snap-1"}`)) |
| 37 | + defer func() { _ = resp.Body.Close() }() |
| 38 | + |
| 39 | + if resp.StatusCode != http.StatusNotImplemented { |
| 40 | + t.Errorf("status: got %d, want 501", resp.StatusCode) |
| 41 | + } |
| 42 | + |
| 43 | + if got := resp.Header.Get("Content-Type"); !strings.HasPrefix(got, "application/json") { |
| 44 | + t.Errorf("Content-Type: got %q, want application/json prefix", got) |
| 45 | + } |
| 46 | +} |
0 commit comments