Skip to content
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

Improve code coverage #40

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions notification_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package transloadit

import (
"strings"
"testing"
)

func TestListNotifications(t *testing.T) {
t.Parallel()

client := setup(t)
_, err := client.ListNotifications(ctx, &ListOptions{
PageSize: 3,
})

if err == nil {
t.Fatal("expected an error but got nil")
}

if !strings.Contains(err.Error(), "no longer available") {
t.Fatalf("unexpected error message: %v", err)
}
}

func TestReplayNotification(t *testing.T) {
t.Parallel()

client := setup(t)

// Create a Assembly to later replay its notifications
assembly := NewAssembly()
assembly.AddFile("image", "./fixtures/lol_cat.jpg")
assembly.AddStep("resize", map[string]interface{}{
"robot": "/image/resize",
"width": 75,
"height": 75,
})
assembly.NotifyURL = "https://transloadit.com/notify-url/"

info, err := client.StartAssembly(ctx, assembly)
if err != nil {
t.Fatal(err)
}

info, err = client.WaitForAssembly(ctx, info)
if err != nil {
t.Fatal(err)
}

// Test replay notification with custom notify URL
if err = client.ReplayNotification(ctx, info.AssemblyID, "https://transloadit.com/custom-notify"); err != nil {
t.Fatal(err)
}
}
15 changes: 0 additions & 15 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,6 @@ func (template *Template) UnmarshalJSON(b []byte) error {
return nil
}

func (template Template) MarshalJSON() ([]byte, error) {
var internal templateInternal

internal.Name = template.Name
internal.Content = template.Content
internal.ID = template.ID
if template.RequireSignatureAuth {
internal.RequireSignatureAuth = 1
} else {
internal.RequireSignatureAuth = 0
}

return json.Marshal(internal)
}

// CreateTemplate will save the provided template struct as a new template
// and return the ID of the new template.
func (client *Client) CreateTemplate(ctx context.Context, template Template) (string, error) {
Expand Down
Loading