1/* 2Copyright 2018 The Doctl Authors All rights reserved. 3Licensed under the Apache License, Version 2.0 (the "License"); 4you may not use this file except in compliance with the License. 5You may obtain a copy of the License at 6 http://www.apache.org/licenses/LICENSE-2.0 7Unless required by applicable law or agreed to in writing, software 8distributed under the License is distributed on an "AS IS" BASIS, 9WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10See the License for the specific language governing permissions and 11limitations under the License. 12*/ 13 14package commands 15 16import ( 17 "testing" 18 "time" 19 20 "github.com/digitalocean/doctl/do" 21 "github.com/digitalocean/godo" 22 "github.com/stretchr/testify/assert" 23) 24 25var testBillingHistoryList = &do.BillingHistory{ 26 BillingHistory: &godo.BillingHistory{ 27 BillingHistory: []godo.BillingHistoryEntry{ 28 { 29 Description: "Invoice for May 2018", 30 Amount: "12.34", 31 InvoiceID: godo.String("123"), 32 InvoiceUUID: godo.String("example-uuid"), 33 Date: time.Date(2018, 6, 1, 8, 44, 38, 0, time.UTC), 34 Type: "Invoice", 35 }, 36 { 37 Description: "Payment (MC 2018)", 38 Amount: "-12.34", 39 InvoiceID: nil, 40 InvoiceUUID: nil, 41 Date: time.Date(2018, 6, 2, 8, 44, 38, 0, time.UTC), 42 Type: "Payment", 43 }, 44 }, 45 }, 46} 47 48func TestBillingHistoryCommand(t *testing.T) { 49 historyCmd := BillingHistory() 50 assert.NotNil(t, historyCmd) 51 assertCommandNames(t, historyCmd, "list") 52} 53 54func TestBillingHistoryList(t *testing.T) { 55 withTestClient(t, func(config *CmdConfig, tm *tcMocks) { 56 tm.billingHistory.EXPECT().List().Return(testBillingHistoryList, nil) 57 58 err := RunBillingHistoryList(config) 59 assert.NoError(t, err) 60 }) 61} 62