github.com/getgauge/gauge@v1.6.9/parser/specFileCollection_test.go (about)

     1  // Copyright 2019 ThoughtWorks, Inc.
     2  
     3  /*----------------------------------------------------------------
     4   *  Copyright (c) ThoughtWorks, Inc.
     5   *  Licensed under the Apache License, Version 2.0
     6   *  See LICENSE in the project root for license information.
     7   *----------------------------------------------------------------*/
     8  
     9  package parser
    10  
    11  import (
    12  	"reflect"
    13  	"testing"
    14  )
    15  
    16  func TestSpecFileCollection(t *testing.T) {
    17  	f1 := "filename1"
    18  	f2 := "filename2"
    19  	f3 := "filename3"
    20  
    21  	collection := NewSpecFileCollection([]string{f1, f2, f3})
    22  
    23  	i1, _ := collection.Next()
    24  	i2, _ := collection.Next()
    25  	i3, _ := collection.Next()
    26  
    27  	got := []string{i1, i2, i3}
    28  	want := []string{f1, f2, f3}
    29  
    30  	if !reflect.DeepEqual(want, got) {
    31  		t.Errorf("Spec Collection Failed\n\tWant: %v\n\t Got:%v", want, got)
    32  	}
    33  }
    34  
    35  func TestSpecFileCollectionWithItems(t *testing.T) {
    36  	collection := NewSpecFileCollection([]string{})
    37  
    38  	i, err := collection.Next()
    39  	if i != "" {
    40  		t.Errorf("Spec Collection Failed\n\tWant: %v\n\t Got:%v", "", i)
    41  	}
    42  	errMessage := "no files in collection"
    43  	if !reflect.DeepEqual(err.Error(), errMessage) {
    44  		t.Errorf("Expected error to be - \n%s\nBut got -\n%s", errMessage, err.Error())
    45  	}
    46  }