| 1 | package api_test |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/CenturyLinkCloud/clc-sdk/api" |
| 7 | "github.com/stretchr/testify/assert" |
| 8 | ) |
| 9 | |
| 10 | func TestGetID_Success(t *testing.T) { |
| 11 | assert := assert.New(t) |
| 12 | |
| 13 | links := api.Links{api.Link{Rel: "a", ID: "1"}} |
| 14 | ok, id := links.GetID("a") |
| 15 | |
| 16 | assert.True(ok) |
| 17 | assert.Equal(id, "1") |
| 18 | } |
| 19 | |
| 20 | func TestGetID_Failure(t *testing.T) { |
| 21 | assert := assert.New(t) |
| 22 | |
| 23 | links := api.Links{api.Link{Rel: "a", ID: "1"}} |
| 24 | ok, id := links.GetID("b") |
| 25 | |
| 26 | assert.False(ok) |
| 27 | assert.Equal(id, "") |
| 28 | } |