Skip to content

Commit

Permalink
Revert "{wip} Add Task Description"
Browse files Browse the repository at this point in the history
This reverts commit ff8b8ac.
  • Loading branch information
glennsarti committed Jun 29, 2022
1 parent ff8b8ac commit 48aa64d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 52 deletions.
8 changes: 3 additions & 5 deletions helper_test.go
Expand Up @@ -776,12 +776,10 @@ func createRunTask(t *testing.T, client *Client, org *Organization) (*RunTask, f
}

ctx := context.Background()
description := randomString(t)
r, err := client.RunTasks.Create(ctx, org.Name, RunTaskCreateOptions{
Name: "tst-" + randomString(t),
URL: runTaskURL,
Description: &description,
Category: "task",
Name: "tst-" + randomString(t),
URL: runTaskURL,
Category: "task",
})
if err != nil {
t.Fatal(err)
Expand Down
19 changes: 6 additions & 13 deletions run_task.go
Expand Up @@ -42,13 +42,12 @@ type runTasks struct {

// RunTask represents a TFC/E run task
type RunTask struct {
ID string `jsonapi:"primary,tasks"`
Name string `jsonapi:"attr,name"`
URL string `jsonapi:"attr,url"`
Description string `jsonapi:"attr,description"`
Category string `jsonapi:"attr,category"`
HMACKey *string `jsonapi:"attr,hmac-key,omitempty"`
Enabled bool `jsonapi:"attr,enabled"`
ID string `jsonapi:"primary,tasks"`
Name string `jsonapi:"attr,name"`
URL string `jsonapi:"attr,url"`
Category string `jsonapi:"attr,category"`
HMACKey *string `jsonapi:"attr,hmac-key,omitempty"`
Enabled bool `jsonapi:"attr,enabled"`

Organization *Organization `jsonapi:"relation,organization"`
WorkspaceRunTasks []*WorkspaceRunTask `jsonapi:"relation,workspace-tasks"`
Expand Down Expand Up @@ -98,9 +97,6 @@ type RunTaskCreateOptions struct {
// Required: The URL to send a run task payload
URL string `jsonapi:"attr,url"`

// Optional: Description of the task
Description *string `jsonapi:"attr,description"`

// Required: Must be "task"
Category string `jsonapi:"attr,category"`

Expand All @@ -125,9 +121,6 @@ type RunTaskUpdateOptions struct {
// Optional: The URL to send a run task payload, defaults to previous value
URL *string `jsonapi:"attr,url,omitempty"`

// Optional: An optional description of the task
Description *string `jsonapi:"attr,description,omitempty"`

// Optional: Must be "task", defaults to "task"
Category *string `jsonapi:"attr,category,omitempty"`

Expand Down
38 changes: 4 additions & 34 deletions run_task_integration_test.go
Expand Up @@ -27,23 +27,20 @@ func TestRunTasksCreate(t *testing.T) {
}

runTaskName := "tst-runtask-" + randomString(t)
runTaskDescription := "A Run Task Description"

t.Run("add run task to organization", func(t *testing.T) {
r, err := client.RunTasks.Create(ctx, orgTest.Name, RunTaskCreateOptions{
Name: runTaskName,
URL: runTaskServerURL,
Description: &runTaskDescription,
Category: "task",
Enabled: Bool(true),
Name: runTaskName,
URL: runTaskServerURL,
Category: "task",
Enabled: Bool(true),
})
require.NoError(t, err)

assert.NotEmpty(t, r.ID)
assert.Equal(t, r.Name, runTaskName)
assert.Equal(t, r.URL, runTaskServerURL)
assert.Equal(t, r.Category, "task")
assert.Equal(t, r.Description, runTaskDescription)

t.Run("ensure org is deserialized properly", func(t *testing.T) {
assert.Equal(t, r.Organization.Name, orgTest.Name)
Expand Down Expand Up @@ -96,7 +93,6 @@ func TestRunTasksRead(t *testing.T) {
assert.Equal(t, runTaskTest.ID, r.ID)
assert.Equal(t, runTaskTest.URL, r.URL)
assert.Equal(t, runTaskTest.Category, r.Category)
assert.Equal(t, runTaskTest.Description, r.Description)
assert.Equal(t, runTaskTest.HMACKey, r.HMACKey)
assert.Equal(t, runTaskTest.Enabled, r.Enabled)
})
Expand Down Expand Up @@ -152,32 +148,6 @@ func TestRunTasksUpdate(t *testing.T) {

assert.Equal(t, rename, r.Name)
})

t.Run("toggle enabled", func(t *testing.T) {
runTaskTest.Enabled = !runTaskTest.Enabled
r, err := client.RunTasks.Update(ctx, runTaskTest.ID, RunTaskUpdateOptions{
Enabled: &runTaskTest.Enabled,
})
require.NoError(t, err)

r, err = client.RunTasks.Read(ctx, r.ID)
require.NoError(t, err)

assert.Equal(t, runTaskTest.Enabled, r.Enabled)
})

t.Run("update description", func(t *testing.T) {
newDescription := "An updated task description"
r, err := client.RunTasks.Update(ctx, runTaskTest.ID, RunTaskUpdateOptions{
Description: &newDescription,
})
require.NoError(t, err)

r, err = client.RunTasks.Read(ctx, r.ID)
require.NoError(t, err)

assert.Equal(t, newDescription, r.Description)
})
}

func TestRunTasksDelete(t *testing.T) {
Expand Down

0 comments on commit 48aa64d

Please sign in to comment.