From f57c41d36afbe92f124537349cd28ba2e09b616d Mon Sep 17 00:00:00 2001 From: Radu Topala Date: Wed, 26 May 2021 20:06:12 +0300 Subject: [PATCH] fixed tests --- .github/workflows/tests.yml | 2 +- exec_test.go | 2 +- options_test.go | 27 +++++++++++++++------------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index acb7976..bf33962 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,7 +4,7 @@ jobs: test: strategy: matrix: - go-version: [1.13] + go-version: [1.15] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: diff --git a/exec_test.go b/exec_test.go index 1d5d0e5..f445ced 100644 --- a/exec_test.go +++ b/exec_test.go @@ -452,4 +452,4 @@ func TestExec_Local(t *testing.T) { require.Equal(t, testCase.wantO, gotO, "Remote() = %v, want %v", gotO, testCase.wantO) }) } -} \ No newline at end of file +} diff --git a/options_test.go b/options_test.go index c04c41c..e581810 100644 --- a/options_test.go +++ b/options_test.go @@ -224,21 +224,22 @@ func TestArgument_String(t *testing.T) { testCases := []testCase{ { - test: "valid with value string type pointer", + test: "invalid with value string type pointer", arg: &Argument{ Name: "argument", Type: String, Value: new(string), }, + expectedPanic: true, }, { - test: "invalid value string type with no pointer", + test: "valid value string type with no pointer", arg: &Argument{ Name: "argument", Type: String, Value: "string", }, - expectedPanic: true, + expectedPanic: false, }, { test: "invalid value int type with no pointer", @@ -258,7 +259,7 @@ func TestArgument_String(t *testing.T) { _ = testCase.arg.String() }) } else { - require.Equal(t, *testCase.arg.Value.(*string), testCase.arg.String()) + require.Equal(t, testCase.arg.Value.(string), testCase.arg.String()) } }) } @@ -273,21 +274,22 @@ func TestArgument_Int(t *testing.T) { testCases := []testCase{ { - test: "valid with value int type pointer", + test: "invalid with value int type pointer", arg: &Argument{ Name: "argument", Type: Int, Value: new(int), }, + expectedPanic: true, }, { - test: "invalid value int type with no pointer", + test: "valid value int type with no pointer", arg: &Argument{ Name: "argument", Type: Int, Value: 0, }, - expectedPanic: true, + expectedPanic: false, }, { test: "invalid value string type with no pointer", @@ -307,7 +309,7 @@ func TestArgument_Int(t *testing.T) { testCase.arg.Int() }) } else { - require.Equal(t, *testCase.arg.Value.(*int), testCase.arg.Int()) + require.Equal(t, testCase.arg.Value.(int), testCase.arg.Int()) } }) } @@ -322,21 +324,22 @@ func TestArgument_Bool(t *testing.T) { testCases := []testCase{ { - test: "valid with value bool type pointer", + test: "invalid with value bool type pointer", arg: &Argument{ Name: "argument", Type: Bool, Value: new(bool), }, + expectedPanic: true, }, { - test: "invalid value bool type with no pointer", + test: "valid value bool type with no pointer", arg: &Argument{ Name: "argument", Type: Bool, Value: false, }, - expectedPanic: true, + expectedPanic: false, }, { test: "invalid value string type with no pointer", @@ -356,7 +359,7 @@ func TestArgument_Bool(t *testing.T) { testCase.arg.Bool() }) } else { - require.Equal(t, *testCase.arg.Value.(*bool), testCase.arg.Bool()) + require.Equal(t, testCase.arg.Value.(bool), testCase.arg.Bool()) } }) }