From 74b1c46b7f1262222ad7263d72f18a6be30ca6a0 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Tue, 7 Mar 2023 15:29:29 -0700 Subject: [PATCH] server(filesystem): fix archive test --- server/filesystem/archive_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/server/filesystem/archive_test.go b/server/filesystem/archive_test.go index 91bbfe7..6c7c730 100644 --- a/server/filesystem/archive_test.go +++ b/server/filesystem/archive_test.go @@ -5,6 +5,7 @@ import ( iofs "io/fs" "os" "path/filepath" + "sort" "strings" "testing" @@ -59,7 +60,7 @@ func TestArchive_Stream(t *testing.T) { }, } - // Create the archive + // Create the archive. archivePath := filepath.Join(rfs.root, "archive.tar.gz") g.Assert(a.Create(context.Background(), archivePath)).IsNil() @@ -80,10 +81,17 @@ func TestArchive_Stream(t *testing.T) { g.Assert(err).IsNil() // Ensure the files in the archive match what we are expecting. - g.Assert(files).Equal([]string{ + expected := []string{ "test_file.txt", "test/file.txt", - }) + } + + // Sort the slices to ensure the comparison never fails if the + // contents are sorted differently. + sort.Strings(expected) + sort.Strings(files) + + g.Assert(files).Equal(expected) }) }) }