func TestNullAPI(test *testing.T) { var api client.API = new(nullAPI) // all the methods return errors, all the time. if _, err := api.Machines(); err == nil { test.Error("Machines() did not return an error") } if _, err := api.Unit("foo"); err == nil { test.Error("Unit() did not return an error") } if _, err := api.Units(); err == nil { test.Error("Units() did not return an error") } if _, err := api.UnitStates(); err == nil { test.Error("UnitStates() did not return an error") } if err := api.SetUnitTargetState("foo", "bar"); err == nil { test.Error("SetUnitTargetState() did not return an error") } if err := api.CreateUnit(nil); err == nil { test.Error("CreateUnit() did not return an error") } if err := api.DestroyUnit("foo"); err == nil { test.Error("DestroyUnit() did not return an error") } }
func getUnitPage(cAPI client.API, tok PageToken) (*schema.UnitPage, error) { units, err := cAPI.Units() if err != nil { return nil, err } items, next := extractUnitPageData(units, tok) page := schema.UnitPage{ Units: items, } if next != nil { page.NextPageToken = next.Encode() } return &page, nil }