forked from LaconicNetwork/kompose
* fix: support host port and protocol in functional tests * feat: add kompose client with options Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> * test: add options unit tests Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> * feat: add partial convert options Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> * feat: finish convert process Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> * test: finish unit tests of the kompose client Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> * remove unecessary changes Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> * feat: add generate network policies to client Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> * update go mod Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> --------- Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
62 lines
1.7 KiB
Go
62 lines
1.7 KiB
Go
package client
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gotest.tools/v3/assert"
|
|
is "gotest.tools/v3/assert/cmp"
|
|
)
|
|
|
|
func TestNewClientWithOpts(t *testing.T) {
|
|
testCases := []struct {
|
|
expectedError error
|
|
expectedSuppressWarnings bool
|
|
expectedVerbose bool
|
|
expectedErrorOnWarnings bool
|
|
opts []Opt
|
|
}{
|
|
{
|
|
expectedError: nil,
|
|
expectedSuppressWarnings: false,
|
|
expectedVerbose: false,
|
|
expectedErrorOnWarnings: false,
|
|
opts: []Opt{},
|
|
},
|
|
{
|
|
expectedError: nil,
|
|
expectedSuppressWarnings: true,
|
|
expectedVerbose: false,
|
|
expectedErrorOnWarnings: false,
|
|
opts: []Opt{WithSuppressWarnings()},
|
|
},
|
|
{
|
|
expectedError: nil,
|
|
expectedSuppressWarnings: false,
|
|
expectedVerbose: true,
|
|
expectedErrorOnWarnings: false,
|
|
opts: []Opt{WithVerboseOutput()},
|
|
},
|
|
{
|
|
expectedError: nil,
|
|
expectedSuppressWarnings: false,
|
|
expectedVerbose: false,
|
|
expectedErrorOnWarnings: true,
|
|
opts: []Opt{WithErrorOnWarning()},
|
|
},
|
|
{
|
|
expectedError: nil,
|
|
expectedSuppressWarnings: true,
|
|
expectedVerbose: false,
|
|
expectedErrorOnWarnings: true,
|
|
opts: []Opt{WithErrorOnWarning(), WithSuppressWarnings()},
|
|
},
|
|
}
|
|
for _, tc := range testCases {
|
|
client, err := NewClient(tc.opts...)
|
|
assert.Check(t, is.Equal(err, tc.expectedError))
|
|
assert.Check(t, is.Equal(client.errorOnWarning, tc.expectedErrorOnWarnings))
|
|
assert.Check(t, is.Equal(client.verbose, tc.expectedVerbose))
|
|
assert.Check(t, is.Equal(client.suppressWarnings, tc.expectedSuppressWarnings))
|
|
}
|
|
}
|