github.com/ojongerius/terraform@v0.7.1-0.20160811111335-97fcd5f4cc90/command/state_test.go (about)

     1  package command
     2  
     3  import (
     4  	"path/filepath"
     5  	"sort"
     6  	"testing"
     7  )
     8  
     9  // testStateBackups returns the list of backups in order of creation
    10  // (oldest first) in the given directory.
    11  func testStateBackups(t *testing.T, dir string) []string {
    12  	// Find all the backups
    13  	list, err := filepath.Glob(filepath.Join(dir, "*"+DefaultBackupExtension))
    14  	if err != nil {
    15  		t.Fatalf("err: %s", err)
    16  	}
    17  
    18  	// Sort them which will put them naturally in the right order
    19  	sort.Strings(list)
    20  
    21  	return list
    22  }