-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move
QemuNetworkInterfaceID
to seperate file
- Loading branch information
1 parent
74f3db4
commit 4ee1619
Showing
4 changed files
with
78 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package proxmox | ||
|
||
import "errors" | ||
|
||
type QemuNetworkInterfaceID uint8 | ||
|
||
const ( | ||
QemuNetworkInterfaceID_Error_Invalid string = "network interface ID must be in the range 0-31" | ||
|
||
QemuNetworkInterfaceID0 QemuNetworkInterfaceID = 0 | ||
QemuNetworkInterfaceID1 QemuNetworkInterfaceID = 1 | ||
QemuNetworkInterfaceID2 QemuNetworkInterfaceID = 2 | ||
QemuNetworkInterfaceID3 QemuNetworkInterfaceID = 3 | ||
QemuNetworkInterfaceID4 QemuNetworkInterfaceID = 4 | ||
QemuNetworkInterfaceID5 QemuNetworkInterfaceID = 5 | ||
QemuNetworkInterfaceID6 QemuNetworkInterfaceID = 6 | ||
QemuNetworkInterfaceID7 QemuNetworkInterfaceID = 7 | ||
QemuNetworkInterfaceID8 QemuNetworkInterfaceID = 8 | ||
QemuNetworkInterfaceID9 QemuNetworkInterfaceID = 9 | ||
QemuNetworkInterfaceID10 QemuNetworkInterfaceID = 10 | ||
QemuNetworkInterfaceID11 QemuNetworkInterfaceID = 11 | ||
QemuNetworkInterfaceID12 QemuNetworkInterfaceID = 12 | ||
QemuNetworkInterfaceID13 QemuNetworkInterfaceID = 13 | ||
QemuNetworkInterfaceID14 QemuNetworkInterfaceID = 14 | ||
QemuNetworkInterfaceID15 QemuNetworkInterfaceID = 15 | ||
QemuNetworkInterfaceID16 QemuNetworkInterfaceID = 16 | ||
QemuNetworkInterfaceID17 QemuNetworkInterfaceID = 17 | ||
QemuNetworkInterfaceID18 QemuNetworkInterfaceID = 18 | ||
QemuNetworkInterfaceID19 QemuNetworkInterfaceID = 19 | ||
QemuNetworkInterfaceID20 QemuNetworkInterfaceID = 20 | ||
QemuNetworkInterfaceID21 QemuNetworkInterfaceID = 21 | ||
QemuNetworkInterfaceID22 QemuNetworkInterfaceID = 22 | ||
QemuNetworkInterfaceID23 QemuNetworkInterfaceID = 23 | ||
QemuNetworkInterfaceID24 QemuNetworkInterfaceID = 24 | ||
QemuNetworkInterfaceID25 QemuNetworkInterfaceID = 25 | ||
QemuNetworkInterfaceID26 QemuNetworkInterfaceID = 26 | ||
QemuNetworkInterfaceID27 QemuNetworkInterfaceID = 27 | ||
QemuNetworkInterfaceID28 QemuNetworkInterfaceID = 28 | ||
QemuNetworkInterfaceID29 QemuNetworkInterfaceID = 29 | ||
QemuNetworkInterfaceID30 QemuNetworkInterfaceID = 30 | ||
QemuNetworkInterfaceID31 QemuNetworkInterfaceID = 31 | ||
|
||
QemuNetworkInterfaceIDMaximum QemuNetworkInterfaceID = QemuNetworkInterfaceID31 | ||
) | ||
|
||
func (id QemuNetworkInterfaceID) Validate() error { | ||
if id > QemuNetworkInterfaceIDMaximum { | ||
return errors.New(QemuNetworkInterfaceID_Error_Invalid) | ||
} | ||
return nil | ||
} |
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,27 @@ | ||
package proxmox | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_QemuNetworkInterfaceID_Validate(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input QemuNetworkInterfaceID | ||
output error | ||
}{ | ||
{name: "Valid", | ||
input: QemuNetworkInterfaceID0}, | ||
{name: "Invalid", | ||
input: 32, | ||
output: errors.New(QemuNetworkInterfaceID_Error_Invalid)}, | ||
} | ||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
require.Equal(t, test.output, test.input.Validate()) | ||
}) | ||
} | ||
} |
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