-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Nasf-Fan/DAOS-15914_1
- Loading branch information
Showing
9 changed files
with
274 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// | ||
// (C) Copyright 2024 Intel Corporation. | ||
// | ||
// SPDX-License-Identifier: BSD-2-Clause-Patent | ||
// | ||
|
||
package system | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/daos-stack/daos/src/control/common/test" | ||
) | ||
|
||
func TestSystem_Errors_IsNotReady(t *testing.T) { | ||
for name, tc := range map[string]struct { | ||
err error | ||
expResult bool | ||
}{ | ||
"nil": {}, | ||
"uninitialized": { | ||
err: ErrUninitialized, | ||
expResult: true, | ||
}, | ||
"raft not available": { | ||
err: ErrRaftUnavail, | ||
expResult: true, | ||
}, | ||
"leadership transfer in progress": { | ||
err: ErrLeaderStepUpInProgress, | ||
expResult: true, | ||
}, | ||
"something else": { | ||
err: errors.New("something is wrong"), | ||
}, | ||
} { | ||
t.Run(name, func(t *testing.T) { | ||
test.AssertEqual(t, tc.expResult, IsNotReady(tc.err), "") | ||
}) | ||
} | ||
} | ||
|
||
func TestSystem_Errors_IsUninitialized(t *testing.T) { | ||
for name, tc := range map[string]struct { | ||
err error | ||
expResult bool | ||
}{ | ||
"nil": {}, | ||
"uninitialized": { | ||
err: ErrUninitialized, | ||
expResult: true, | ||
}, | ||
"unavailable not uninitialized": { | ||
err: ErrRaftUnavail, | ||
}, | ||
"something else": { | ||
err: errors.New("something is wrong"), | ||
}, | ||
} { | ||
t.Run(name, func(t *testing.T) { | ||
test.AssertEqual(t, tc.expResult, IsUninitialized(tc.err), "") | ||
}) | ||
} | ||
} | ||
|
||
func TestSystem_Errors_IsUnavailable(t *testing.T) { | ||
for name, tc := range map[string]struct { | ||
err error | ||
expResult bool | ||
}{ | ||
"nil": {}, | ||
"raft not available": { | ||
err: ErrRaftUnavail, | ||
expResult: true, | ||
}, | ||
"leadership transfer in progress": { | ||
err: ErrLeaderStepUpInProgress, | ||
expResult: true, | ||
}, | ||
"uninitialized not unavailable": { | ||
err: ErrUninitialized, | ||
}, | ||
"something else": { | ||
err: errors.New("something is wrong"), | ||
}, | ||
} { | ||
t.Run(name, func(t *testing.T) { | ||
test.AssertEqual(t, tc.expResult, IsUnavailable(tc.err), "") | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.