Go client for the Write.as API https://developers.write.as
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

42 行
746 B

  1. package writeas
  2. import (
  3. "context"
  4. "testing"
  5. )
  6. func TestClient_CreateContributor(t *testing.T) {
  7. c := NewClientWith(Config{URL: "http://localhost:7777/api"})
  8. ctx := context.Background()
  9. _, err := c.LogIn(ctx, "test", "test")
  10. if err != nil {
  11. t.Fatalf("login: %s", err)
  12. }
  13. tests := []struct {
  14. name string
  15. AName string
  16. ASlug string
  17. AOrg string
  18. }{
  19. {
  20. name: "good",
  21. AName: "Bob Contrib",
  22. ASlug: "bob",
  23. AOrg: "write-as",
  24. },
  25. }
  26. for _, test := range tests {
  27. t.Run(test.name, func(t *testing.T) {
  28. _, err = c.CreateContributor(ctx, &AuthorParams{
  29. Name: test.AName,
  30. Slug: test.ASlug,
  31. OrgAlias: test.AOrg,
  32. })
  33. if err != nil {
  34. t.Fatalf("create %s: %s", test.name, err)
  35. }
  36. })
  37. }
  38. }