github.com/getgauge/gauge@v1.6.9/order/sort_test.go (about)

     1  /*----------------------------------------------------------------
     2   *  Copyright (c) ThoughtWorks, Inc.
     3   *  Licensed under the Apache License, Version 2.0
     4   *  See LICENSE in the project root for license information.
     5   *----------------------------------------------------------------*/
     6  package order
     7  
     8  import (
     9  	"testing"
    10  
    11  	"github.com/getgauge/gauge/gauge"
    12  )
    13  
    14  func TestToSortSpecs(t *testing.T) {
    15  	spec1 := &gauge.Specification{FileName: "ab"}
    16  	spec2 := &gauge.Specification{FileName: "b"}
    17  	spec3 := &gauge.Specification{FileName: "c"}
    18  	var specs []*gauge.Specification
    19  	specs = append(specs, spec3)
    20  	specs = append(specs, spec1)
    21  	specs = append(specs, spec2)
    22  
    23  	Sorted = true
    24  	got := Sort(specs)
    25  	expected := []*gauge.Specification{spec1, spec2, spec3}
    26  
    27  	for i, s := range got {
    28  		if expected[i].FileName != s.FileName {
    29  			t.Errorf("Expected '%s' at position %d, got %s", expected[i].FileName, i, s.FileName)
    30  		}
    31  	}
    32  }