mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 05:36:12 +00:00
Fix test not use test flags
This commit is contained in:
@@ -47,30 +47,30 @@ func TestCreateQuota(t *testing.T) {
|
|||||||
tf.Namespace = "test"
|
tf.Namespace = "test"
|
||||||
|
|
||||||
tests := map[string]struct {
|
tests := map[string]struct {
|
||||||
flags map[string]string
|
flags []string
|
||||||
expectedOutput string
|
expectedOutput string
|
||||||
}{
|
}{
|
||||||
"single resource": {
|
"single resource": {
|
||||||
flags: map[string]string{"hard": "cpu=1", "output": "name"},
|
flags: []string{"--hard=cpu=1"},
|
||||||
expectedOutput: "resourcequota/" + resourceQuotaObject.Name + "\n",
|
expectedOutput: "resourcequota/" + resourceQuotaObject.Name + "\n",
|
||||||
},
|
},
|
||||||
"single resource with a scope": {
|
"single resource with a scope": {
|
||||||
flags: map[string]string{"hard": "cpu=1", "output": "name", "scopes": "BestEffort"},
|
flags: []string{"--hard=cpu=1", "--scopes=BestEffort"},
|
||||||
expectedOutput: "resourcequota/" + resourceQuotaObject.Name + "\n",
|
expectedOutput: "resourcequota/" + resourceQuotaObject.Name + "\n",
|
||||||
},
|
},
|
||||||
"multiple resources": {
|
"multiple resources": {
|
||||||
flags: map[string]string{"hard": "cpu=1,pods=42", "output": "name", "scopes": "BestEffort"},
|
flags: []string{"--hard=cpu=1,pods=42", "--scopes=BestEffort"},
|
||||||
expectedOutput: "resourcequota/" + resourceQuotaObject.Name + "\n",
|
expectedOutput: "resourcequota/" + resourceQuotaObject.Name + "\n",
|
||||||
},
|
},
|
||||||
"single resource with multiple scopes": {
|
"single resource with multiple scopes": {
|
||||||
flags: map[string]string{"hard": "cpu=1", "output": "name", "scopes": "BestEffort,NotTerminating"},
|
flags: []string{"--hard=cpu=1", "--scopes=BestEffort,NotTerminating"},
|
||||||
expectedOutput: "resourcequota/" + resourceQuotaObject.Name + "\n",
|
expectedOutput: "resourcequota/" + resourceQuotaObject.Name + "\n",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for name, test := range tests {
|
for name, test := range tests {
|
||||||
buf := bytes.NewBuffer([]byte{})
|
buf := bytes.NewBuffer([]byte{})
|
||||||
cmd := NewCmdCreateQuota(f, buf)
|
cmd := NewCmdCreateQuota(f, buf)
|
||||||
cmd.Flags().Set("hard", "cpu=1")
|
cmd.Flags().Parse(test.flags)
|
||||||
cmd.Flags().Set("output", "name")
|
cmd.Flags().Set("output", "name")
|
||||||
cmd.Run(cmd, []string{resourceQuotaObject.Name})
|
cmd.Run(cmd, []string{resourceQuotaObject.Name})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user