-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Task] Support the deployment when creating resources. #257
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #257 +/- ##
===========================================
+ Coverage 78.27% 79.74% +1.46%
===========================================
Files 53 55 +2
Lines 2656 3041 +385
===========================================
+ Hits 2079 2425 +346
- Misses 438 469 +31
- Partials 139 147 +8
Continue to review full report at Codecov.
|
src/entity/deployment.go
Outdated
ID bson.ObjectId `bson:"_id,omitempty" json:"id" validate:"-"` | ||
Name string `bson:"name" json:"name" validate:"required,k8sname"` | ||
Namespace string `bson:"namespace" json:"namespace" validate:"required"` | ||
Labels map[string]string `bson:"labels,omitempty" json:"labels" validate:"required,dive,keys,alphanum,endkeys,required,alphanum"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using printascii
here?
}, | ||
} | ||
tName := namesgenerator.GetRandomName(0) | ||
pod := entity.Deployment{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable name
deployment := entity.Deployment{
NodeAffinity: []string{}, | ||
Replicas: 1, | ||
} | ||
bodyBytes, err := json.MarshalIndent(pod, "", " ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bodyBytes, err := json.MarshalIndent(deployment, "", " ")
httpWriter := httptest.NewRecorder() | ||
suite.wc.Dispatch(httpWriter, httpRequest) | ||
assertResponseCode(suite.T(), http.StatusCreated, httpWriter) | ||
defer suite.session.Remove(entity.DeploymentCollectionName, "name", pod.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer suite.session.Remove(entity.DeploymentCollectionName, "name", deployment.Name)
|
||
//load data to check | ||
retDeployment := entity.Deployment{} | ||
err = suite.session.FindOne(entity.DeploymentCollectionName, bson.M{"name": pod.Name}, &retDeployment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err = suite.session.FindOne(entity.DeploymentCollectionName, bson.M{"name": deployment.Name}, &retDeployment)
suite.NoError(err) | ||
suite.NotEqual("", retDeployment.ID) | ||
suite.Equal(pod.Name, retDeployment.Name) | ||
suite.Equal(len(pod.Containers), len(retDeployment.Containers)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suite.Equal(len(deployment.Containers), len(retDeployment.Containers))
err = json.Unmarshal(httpWriter.Body.Bytes(), &pod) | ||
suite.NoError(err) | ||
suite.Equal(tName, pod.Name) | ||
suite.Equal(len(containers), len(pod.Containers)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suite.Equal(len(containers), len(deployment.Containers))
pod = entity.Deployment{} | ||
err = json.Unmarshal(httpWriter.Body.Bytes(), &pod) | ||
suite.NoError(err) | ||
suite.Equal(tName, pod.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suite.Equal(tName, deployment.Name)
assertResponseCode(suite.T(), http.StatusOK, httpWriter) | ||
|
||
pod = entity.Deployment{} | ||
err = json.Unmarshal(httpWriter.Body.Bytes(), &pod) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err = json.Unmarshal(httpWriter.Body.Bytes(), &deployment)
}, | ||
} | ||
tName := namesgenerator.GetRandomName(0) | ||
pod := entity.Deployment{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deployment := entity.Deployment{
DeletePropagationForeground
to delete deployment.