Browse code

client/volume: use gotest.tools-style asserts

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>

Paweł Gronowski authored on 2025/05/17 02:14:49
Showing 4 changed files
... ...
@@ -60,16 +60,8 @@ func TestVolumeCreate(t *testing.T) {
60 60
 			"opt-key": "opt-value",
61 61
 		},
62 62
 	})
63
-	if err != nil {
64
-		t.Fatal(err)
65
-	}
66
-	if vol.Name != "volume" {
67
-		t.Fatalf("expected volume.Name to be 'volume', got %s", vol.Name)
68
-	}
69
-	if vol.Driver != "local" {
70
-		t.Fatalf("expected volume.Driver to be 'local', got %s", vol.Driver)
71
-	}
72
-	if vol.Mountpoint != "mountpoint" {
73
-		t.Fatalf("expected volume.Mountpoint to be 'mountpoint', got %s", vol.Mountpoint)
74
-	}
63
+	assert.NilError(t, err)
64
+	assert.Check(t, is.Equal(vol.Name, "volume"))
65
+	assert.Check(t, is.Equal(vol.Driver, "local"))
66
+	assert.Check(t, is.Equal(vol.Mountpoint, "mountpoint"))
75 67
 }
... ...
@@ -81,11 +81,7 @@ func TestVolumeList(t *testing.T) {
81 81
 		}
82 82
 
83 83
 		volumeResponse, err := client.VolumeList(context.Background(), volume.ListOptions{Filters: listCase.filters})
84
-		if err != nil {
85
-			t.Fatal(err)
86
-		}
87
-		if len(volumeResponse.Volumes) != 1 {
88
-			t.Fatalf("expected 1 volume, got %v", volumeResponse.Volumes)
89
-		}
84
+		assert.NilError(t, err)
85
+		assert.Check(t, is.Len(volumeResponse.Volumes, 1))
90 86
 	}
91 87
 }
... ...
@@ -62,7 +62,5 @@ func TestVolumeRemove(t *testing.T) {
62 62
 	}
63 63
 
64 64
 	err := client.VolumeRemove(context.Background(), "volume_id", false)
65
-	if err != nil {
66
-		t.Fatal(err)
67
-	}
65
+	assert.NilError(t, err)
68 66
 }
... ...
@@ -56,7 +56,5 @@ func TestVolumeUpdate(t *testing.T) {
56 56
 	}
57 57
 
58 58
 	err := client.VolumeUpdate(context.Background(), "test1", swarm.Version{Index: uint64(10)}, volumetypes.UpdateOptions{})
59
-	if err != nil {
60
-		t.Fatal(err)
61
-	}
59
+	assert.NilError(t, err)
62 60
 }