File: helpers_test.go

package info (click to toggle)
golang-github-fsouza-go-dockerclient 1.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,340 kB
  • sloc: makefile: 26
file content (54 lines) | stat: -rw-r--r-- 1,587 bytes parent folder | download | duplicates (3)
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
// Copyright 2020 go-dockerclient authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package docker

import (
	"errors"
	"testing"
)

func expectNoSuchContainer(t *testing.T, id string, err error) {
	t.Helper()
	var containerErr *NoSuchContainer
	if !errors.As(err, &containerErr) {
		t.Fatalf("Container: Wrong error information. Want %#v. Got %#v.", containerErr, err)
	}
	if containerErr.ID != id {
		t.Errorf("Container: wrong container in error\nWant %q\ngot  %q", id, containerErr.ID)
	}
}

func expectNoSuchNode(t *testing.T, nodeID string, err error) {
	t.Helper()
	var nodeErr *NoSuchNode
	if !errors.As(err, &nodeErr) {
		t.Fatalf("Node: Wrong error information. Want %#v. Got %#v.", nodeErr, err)
	}
	if nodeErr.ID != nodeID {
		t.Errorf("Node: wrong node in error\nWant %q\ngot  %q", nodeID, nodeErr.ID)
	}
}

func expectNoSuchSecret(t *testing.T, secretID string, err error) {
	t.Helper()
	var nodeErr *NoSuchSecret
	if !errors.As(err, &nodeErr) {
		t.Fatalf("Secret: Wrong error information. Want %#v. Got %#v.", nodeErr, err)
	}
	if nodeErr.ID != secretID {
		t.Errorf("Secret: wrong secret in error\nWant %q\ngot  %q", secretID, nodeErr.ID)
	}
}

func expectNoSuchConfig(t *testing.T, secretID string, err error) {
	t.Helper()
	var nodeErr *NoSuchConfig
	if !errors.As(err, &nodeErr) {
		t.Fatalf("Config: Wrong error information. Want %#v. Got %#v.", nodeErr, err)
	}
	if nodeErr.ID != secretID {
		t.Errorf("Config: wrong secret in error\nWant %q\ngot  %q", secretID, nodeErr.ID)
	}
}