diff --git a/notification_test.go b/notification_test.go new file mode 100644 index 0000000..21f4cc8 --- /dev/null +++ b/notification_test.go @@ -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) + } +} diff --git a/template.go b/template.go index 4e61f37..2c4f658 100644 --- a/template.go +++ b/template.go @@ -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) {