mirror of
https://github.com/luxfi/cli.git
synced 2026-10-30 17:01:20 +00:00
- Update github.com/luxfi/netrunner v1.15.3 → v1.15.4 - Update github.com/luxfi/node v1.22.77 → v1.22.80 - Remove local replace directive for netrunner - Use published package versions for reproducible builds
82 lines
1.3 KiB
Go
82 lines
1.3 KiB
Go
// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package flags
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestMutuallyExclusive(t *testing.T) {
|
|
require := require.New(t)
|
|
type test struct {
|
|
flagA bool
|
|
flagB bool
|
|
flagC bool
|
|
expectError bool
|
|
}
|
|
|
|
tests := []test{
|
|
{
|
|
flagA: false,
|
|
flagB: false,
|
|
flagC: false,
|
|
expectError: false,
|
|
},
|
|
{
|
|
flagA: true,
|
|
flagB: false,
|
|
flagC: false,
|
|
expectError: false,
|
|
},
|
|
{
|
|
flagA: false,
|
|
flagB: true,
|
|
flagC: false,
|
|
expectError: false,
|
|
},
|
|
{
|
|
flagA: false,
|
|
flagB: false,
|
|
flagC: true,
|
|
expectError: false,
|
|
},
|
|
{
|
|
flagA: true,
|
|
flagB: false,
|
|
flagC: true,
|
|
expectError: true,
|
|
},
|
|
{
|
|
flagA: false,
|
|
flagB: true,
|
|
flagC: true,
|
|
expectError: true,
|
|
},
|
|
{
|
|
flagA: true,
|
|
flagB: true,
|
|
flagC: false,
|
|
expectError: true,
|
|
},
|
|
{
|
|
flagA: true,
|
|
flagB: true,
|
|
flagC: true,
|
|
expectError: true,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
flags := []bool{tt.flagA, tt.flagB, tt.flagC}
|
|
isEx := EnsureMutuallyExclusive(flags)
|
|
if tt.expectError {
|
|
require.False(isEx)
|
|
} else {
|
|
require.True(isEx)
|
|
}
|
|
}
|
|
}
|