From 5e8fd897e13a40074ef25de1bc0b32d65c4bf714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Fri, 16 May 2025 19:14:49 +0200 Subject: [PATCH] client/volume: use gotest.tools-style asserts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- client/volume_create_test.go | 16 ++++------------ client/volume_list_test.go | 8 ++------ client/volume_remove_test.go | 4 +--- client/volume_update_test.go | 4 +--- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/client/volume_create_test.go b/client/volume_create_test.go index 4d33e7284e..5a6e4d7ef7 100644 --- a/client/volume_create_test.go +++ b/client/volume_create_test.go @@ -60,16 +60,8 @@ func TestVolumeCreate(t *testing.T) { "opt-key": "opt-value", }, }) - if err != nil { - t.Fatal(err) - } - if vol.Name != "volume" { - t.Fatalf("expected volume.Name to be 'volume', got %s", vol.Name) - } - if vol.Driver != "local" { - t.Fatalf("expected volume.Driver to be 'local', got %s", vol.Driver) - } - if vol.Mountpoint != "mountpoint" { - t.Fatalf("expected volume.Mountpoint to be 'mountpoint', got %s", vol.Mountpoint) - } + assert.NilError(t, err) + assert.Check(t, is.Equal(vol.Name, "volume")) + assert.Check(t, is.Equal(vol.Driver, "local")) + assert.Check(t, is.Equal(vol.Mountpoint, "mountpoint")) } diff --git a/client/volume_list_test.go b/client/volume_list_test.go index d393f7d1de..2dcfcc0c76 100644 --- a/client/volume_list_test.go +++ b/client/volume_list_test.go @@ -81,11 +81,7 @@ func TestVolumeList(t *testing.T) { } volumeResponse, err := client.VolumeList(context.Background(), volume.ListOptions{Filters: listCase.filters}) - if err != nil { - t.Fatal(err) - } - if len(volumeResponse.Volumes) != 1 { - t.Fatalf("expected 1 volume, got %v", volumeResponse.Volumes) - } + assert.NilError(t, err) + assert.Check(t, is.Len(volumeResponse.Volumes, 1)) } } diff --git a/client/volume_remove_test.go b/client/volume_remove_test.go index 11fa99d033..219e659d21 100644 --- a/client/volume_remove_test.go +++ b/client/volume_remove_test.go @@ -62,7 +62,5 @@ func TestVolumeRemove(t *testing.T) { } err := client.VolumeRemove(context.Background(), "volume_id", false) - if err != nil { - t.Fatal(err) - } + assert.NilError(t, err) } diff --git a/client/volume_update_test.go b/client/volume_update_test.go index 64cc7e64c4..c4bc774c93 100644 --- a/client/volume_update_test.go +++ b/client/volume_update_test.go @@ -56,7 +56,5 @@ func TestVolumeUpdate(t *testing.T) { } err := client.VolumeUpdate(context.Background(), "test1", swarm.Version{Index: uint64(10)}, volumetypes.UpdateOptions{}) - if err != nil { - t.Fatal(err) - } + assert.NilError(t, err) }