diff options
author | 2020-07-29 01:37:15 +0000 | |
---|---|---|
committer | 2020-08-05 23:03:58 +0000 | |
commit | 11dda8300d3872f9414e7fff0402fd6fcbf6d537 (patch) | |
tree | 623f1df58e6964c19eedae9cbd983a0971be26ee /src/dcm/pkg/module/quota_test.go | |
parent | 2300429de7a5b316172c549456f91a68cba89f83 (diff) |
DCM - fix code formatting via vscode (II)
Part two of fixing code format/syntax with Visual Studio Code.
Furthermore, also switched line endings from CRLF to LF (all test
files seemed to be ending this way, unlike the other Go files).
Issue-ID: MULTICLOUD-1143
Signed-off-by: Igor D.C <igor.duarte.cardoso@intel.com>
Change-Id: Iaae868c780a42ea82ca1208e3cbdc3ec6ffd1f97
Diffstat (limited to 'src/dcm/pkg/module/quota_test.go')
-rw-r--r-- | src/dcm/pkg/module/quota_test.go | 227 |
1 files changed, 112 insertions, 115 deletions
diff --git a/src/dcm/pkg/module/quota_test.go b/src/dcm/pkg/module/quota_test.go index 87a60d71..5b70cf77 100644 --- a/src/dcm/pkg/module/quota_test.go +++ b/src/dcm/pkg/module/quota_test.go @@ -1,115 +1,112 @@ -package module
-
-import (
- "testing"
-
- "github.com/pkg/errors"
-
-)
-
-
-func TestCreateQuota(t *testing.T) {
-
- mData := QMetaDataList{
- QuotaName: "test_quota",
- }
-
- q := Quota {
- MetaData: mData,
- }
- data1 := [][]byte{}
-
-
- key := QuotaKey{
- Project: "test_project",
- LogicalCloudName: "test_asdf",
- QuotaName: "test_quota",
- }
- myMocks := new(mockValues)
- // just to get an error value
- err1 := errors.New("math: square root of negative number")
-
- myMocks.On("CheckProject", "test_project").Return(nil)
- myMocks.On("CheckLogicalCloud", "test_project", "test_asdf").Return(nil)
- myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", q).Return(nil)
- myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, err1)
-
- qClient := QuotaClient{"test_dcm", "test_meta", myMocks}
- _, err := qClient.CreateQuota("test_project", "test_asdf", q)
- if err != nil {
- t.Errorf("Some error occured!")
- }
-}
-
-func TestGetQuota(t *testing.T) {
- key := QuotaKey{
- Project: "test_project",
- LogicalCloudName: "test_asdf",
- QuotaName: "test_quota",
- }
-
- data1 := [][]byte{
- []byte("abc"),
- }
-
- data2 := []byte("abc")
-
- myMocks := new(mockValues)
-
- myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil)
- myMocks.On("DBUnmarshal", data2).Return(nil)
- qClient := QuotaClient{"test_dcm", "test_meta", myMocks}
- _, err := qClient.GetQuota("test_project", "test_asdf", "test_quota")
- if err != nil {
- t.Errorf("Some error occured!")
- }
-}
-
-func TestDeleteQuota(t *testing.T) {
-
- key := QuotaKey{
- Project: "test_project",
- LogicalCloudName: "test_asdf",
- QuotaName: "test_quota",
- }
-
- myMocks := new(mockValues)
-
- myMocks.On("DBRemove", "test_dcm", key).Return(nil)
-
- qClient := QuotaClient{"test_dcm", "test_meta", myMocks}
- err := qClient.DeleteQuota("test_project", "test_asdf", "test_quota")
- if err != nil {
- t.Errorf("Some error occured!")
- }
-
-}
-
-func TestUpdateQuota(t *testing.T) {
- key := QuotaKey{
- Project: "test_project",
- LogicalCloudName: "test_asdf",
- QuotaName: "test_quota",
- }
- mData := QMetaDataList{
- QuotaName: "test_quota",
- }
- q := Quota{
- MetaData: mData,
- }
- data1 := [][]byte{
- []byte("abc"),
- }
- data2 := []byte("abc")
-
- myMocks := new(mockValues)
-
- myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", q).Return(nil)
- myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil)
- myMocks.On("DBUnmarshal", data2).Return(nil)
- qClient := QuotaClient{"test_dcm", "test_meta", myMocks}
- _, err := qClient.UpdateQuota("test_project", "test_asdf", "test_quota", q)
- if err != nil {
- t.Errorf("Some error occured!")
- }
-}
+package module + +import ( + "testing" + + "github.com/pkg/errors" +) + +func TestCreateQuota(t *testing.T) { + + mData := QMetaDataList{ + QuotaName: "test_quota", + } + + q := Quota{ + MetaData: mData, + } + data1 := [][]byte{} + + key := QuotaKey{ + Project: "test_project", + LogicalCloudName: "test_asdf", + QuotaName: "test_quota", + } + myMocks := new(mockValues) + // just to get an error value + err1 := errors.New("math: square root of negative number") + + myMocks.On("CheckProject", "test_project").Return(nil) + myMocks.On("CheckLogicalCloud", "test_project", "test_asdf").Return(nil) + myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", q).Return(nil) + myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, err1) + + qClient := QuotaClient{"test_dcm", "test_meta", myMocks} + _, err := qClient.CreateQuota("test_project", "test_asdf", q) + if err != nil { + t.Errorf("Some error occured!") + } +} + +func TestGetQuota(t *testing.T) { + key := QuotaKey{ + Project: "test_project", + LogicalCloudName: "test_asdf", + QuotaName: "test_quota", + } + + data1 := [][]byte{ + []byte("abc"), + } + + data2 := []byte("abc") + + myMocks := new(mockValues) + + myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil) + myMocks.On("DBUnmarshal", data2).Return(nil) + qClient := QuotaClient{"test_dcm", "test_meta", myMocks} + _, err := qClient.GetQuota("test_project", "test_asdf", "test_quota") + if err != nil { + t.Errorf("Some error occured!") + } +} + +func TestDeleteQuota(t *testing.T) { + + key := QuotaKey{ + Project: "test_project", + LogicalCloudName: "test_asdf", + QuotaName: "test_quota", + } + + myMocks := new(mockValues) + + myMocks.On("DBRemove", "test_dcm", key).Return(nil) + + qClient := QuotaClient{"test_dcm", "test_meta", myMocks} + err := qClient.DeleteQuota("test_project", "test_asdf", "test_quota") + if err != nil { + t.Errorf("Some error occured!") + } + +} + +func TestUpdateQuota(t *testing.T) { + key := QuotaKey{ + Project: "test_project", + LogicalCloudName: "test_asdf", + QuotaName: "test_quota", + } + mData := QMetaDataList{ + QuotaName: "test_quota", + } + q := Quota{ + MetaData: mData, + } + data1 := [][]byte{ + []byte("abc"), + } + data2 := []byte("abc") + + myMocks := new(mockValues) + + myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", q).Return(nil) + myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil) + myMocks.On("DBUnmarshal", data2).Return(nil) + qClient := QuotaClient{"test_dcm", "test_meta", myMocks} + _, err := qClient.UpdateQuota("test_project", "test_asdf", "test_quota", q) + if err != nil { + t.Errorf("Some error occured!") + } +} |