From c0abcb6dee76f36ae2ad67bc003fd1ae81c64994 Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Sun, 10 Dec 2023 20:49:04 +0300 Subject: [PATCH] feat: add test for extract --- helpers_test.go | 33 +++++++++++++++++++++++++++++++++ testdata/archive.tar.gz | Bin 0 -> 153 bytes 2 files changed, 33 insertions(+) create mode 100644 testdata/archive.tar.gz diff --git a/helpers_test.go b/helpers_test.go index 97207e1..5f3b82f 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -1,6 +1,7 @@ package gobrew import ( + "path/filepath" "testing" "github.com/stretchr/testify/assert" @@ -135,3 +136,35 @@ func TestExtractMajorVersion(t *testing.T) { }) } } + +func TestGoBrew_extract(t *testing.T) { + t.Parallel() + type args struct { + srcTar string + dstDir string + } + tests := []struct { + name string + args args + wantErr bool + }{ + { + name: "arhive.tar.gz", + args: args{ + srcTar: "testdata/archive.tar.gz", + dstDir: "tmp", + }, + wantErr: false, + }, + } + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + gb := NewGoBrew(t.TempDir()) + if err := gb.extract(tt.args.srcTar, filepath.Join(t.TempDir(), tt.args.dstDir)); (err != nil) != tt.wantErr { + t.Errorf("GoBrew.extract() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/testdata/archive.tar.gz b/testdata/archive.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..bdde6fc106ad0cfca3fe8896811da438e4b719c3 GIT binary patch literal 153 zcmV;K0A~LmiwFR(^mSzb1MQJZ3d1lAM12%p!0E`5VtSku918tFV;6e-Iv=`dq0ogF zC4QUP4AMx$4exiREC9SJ&Dt#rCyTBSi?-T&#{vR7@70hN&NXw7sULHcOFY@*&0Y`I z0rKg~wqf`(XT9U4e*#bakKr8p7@G7*C3fV0bRxg>uPkB+CBnS3@%}57%654I0gXaO H00;m8!Iwsb literal 0 HcmV?d00001