Пример #1
0
func TestUpdateJob(t *testing.T) {
	job := &models.Job{
		Title:       "my job",
		Description: "whacko job",
	}
	pathURL := fmt.Sprintf("%s/api/jobs", ts.URL)
	rst := models.Job{}
	err := com.HttpPostJSON(client, pathURL, job, &rst)
	if err != nil {
		t.Errorf("creating a job %v", err)
	}
	if rst.Title != job.Title {
		t.Errorf("expected %s got %s", job.Title, rst.Title)
	}
	rst.Description = "a changed world"
	upRst := models.Job{}
	err = httpPutJSON(client, pathURL, &rst, upRst)
	if err != nil {
		t.Error(err)
	}
	check := models.Job{}
	q := db.Conn.Where(&models.Job{ID: rst.ID}).First(&check)
	if q.Error != nil {
		t.Error(q.Error)
	}

	if check.Description != rst.Description {
		t.Errorf("expected %s got %s", rst.Description, check.Description)
	}

}
Пример #2
0
//
//
//		JOB API
//
//
func TestCreateJob(t *testing.T) {
	job := &models.Job{
		Title:       "my job",
		Description: "whacko job",
	}
	pathURL := fmt.Sprintf("%s/api/jobs", ts.URL)
	rst := models.Job{}
	err := com.HttpPostJSON(client, pathURL, job, &rst)
	if err != nil {
		t.Errorf("creating a job %v", err)
	}
	if rst.Title != job.Title {
		t.Errorf("expected %s got %s", job.Title, rst.Title)
	}

}