Просмотр исходного кода

Revert "DeleteCollection: Make params a struct"

This reverts commit 1d34eede72.
pull/13/head
Matt Baer 4 лет назад
Родитель
Сommit
7a2c93ae6d
2 измененных файлов: 4 добавлений и 12 удалений
  1. +2
    -8
      collection.go
  2. +2
    -4
      collection_test.go

+ 2
- 8
collection.go Просмотреть файл

@@ -29,12 +29,6 @@ type (
Alias string `json:"alias"`
Title string `json:"title"`
}

// DeleteCollectionParams holds the parameters required to delete a
// collection.
DeleteCollectionParams struct {
Alias string `json:"-"`
}
)

// CreateCollection creates a new collection, returning a user-friendly error
@@ -146,8 +140,8 @@ func (c *Client) GetUserCollections() (*[]Collection, error) {
// anonymous.
//
// See https://developers.write.as/docs/api/#delete-a-collection.
func (c *Client) DeleteCollection(p *DeleteCollectionParams) error {
endpoint := "/collections/" + p.Alias
func (c *Client) DeleteCollection(alias string) error {
endpoint := "/collections/" + alias
env, err := c.delete(endpoint, nil /* data */)
if err != nil {
return err


+ 2
- 4
collection_test.go Просмотреть файл

@@ -71,8 +71,7 @@ func TestCreateAndDeleteCollection(t *testing.T) {
t.Fatalf("Unable to create collection %q: %v", alias, err)
}

p := &DeleteCollectionParams{Alias: c.Alias}
if err := wac.DeleteCollection(p); err != nil {
if err := wac.DeleteCollection(c.Alias); err != nil {
t.Fatalf("Unable to delete collection %q: %v", alias, err)
}
}
@@ -82,8 +81,7 @@ func TestDeleteCollectionUnauthenticated(t *testing.T) {

now := time.Now().Unix()
alias := fmt.Sprintf("test-collection-does-not-exist-%v", now)
p := &DeleteCollectionParams{Alias: alias}
err := wac.DeleteCollection(p)
err := wac.DeleteCollection(alias)
if err == nil {
t.Fatalf("Should not be able to delete collection %q unauthenticated.", alias)
}


Загрузка…
Отмена
Сохранить