github.com/scaleway/scaleway-cli@v1.11.1/pkg/commands/history_test.go (about)

     1  // Copyright (C) 2015 Scaleway. All rights reserved.
     2  // Use of this source code is governed by a MIT-style
     3  // license that can be found in the LICENSE.md file.
     4  
     5  package commands
     6  
     7  import (
     8  	"fmt"
     9  	"strings"
    10  	"testing"
    11  
    12  	. "github.com/smartystreets/goconvey/convey"
    13  )
    14  
    15  func ExampleRunHistory() {
    16  	ctx := testCommandContext()
    17  	args := HistoryArgs{}
    18  	RunHistory(ctx, args)
    19  }
    20  
    21  func ExampleRunHistory_complex() {
    22  	ctx := testCommandContext()
    23  	args := HistoryArgs{
    24  		NoTrunc: false,
    25  		Quiet:   false,
    26  		Image:   "",
    27  	}
    28  	RunHistory(ctx, args)
    29  }
    30  
    31  func TestRunHistory_realAPI(t *testing.T) {
    32  	ctx := RealAPIContext()
    33  	if ctx == nil {
    34  		t.Skip()
    35  	}
    36  	Convey("Testing RunHistory() on real API", t, func() {
    37  		Convey("ubuntu-wily", func() {
    38  			args := HistoryArgs{
    39  				NoTrunc: false,
    40  				Quiet:   false,
    41  				Image:   "ubuntu-wily",
    42  				Arch:    "arm",
    43  			}
    44  
    45  			scopedCtx, scopedStdout, scopedStderr := getScopedCtx(ctx)
    46  			err := RunHistory(*scopedCtx, args)
    47  			So(err, ShouldBeNil)
    48  			So(scopedStderr.String(), ShouldBeEmpty)
    49  
    50  			lines := strings.Split(scopedStdout.String(), "\n")
    51  			So(len(lines), ShouldBeGreaterThan, 0)
    52  
    53  			firstLine := lines[0]
    54  			colNames := strings.Fields(firstLine)
    55  			So(colNames, ShouldResemble, []string{"IMAGE", "CREATED", "CREATED", "BY", "SIZE"})
    56  
    57  			fmt.Println(scopedStdout.String())
    58  		})
    59  
    60  		// FIXME: test invalid image
    61  		// FIXME: test image with duplicates cache
    62  		// FIXME: test quiet
    63  		// FIXME: test no-trunc
    64  	})
    65  }