github.com/vlifesystems/rulehunter@v0.0.0-20180501090014-673078aa4a83/fileinfo/fileinfo_test.go (about)

     1  package fileinfo
     2  
     3  import (
     4  	"github.com/vlifesystems/rulehunter/internal/testhelpers"
     5  	"testing"
     6  	"time"
     7  )
     8  
     9  func TestIsEqual(t *testing.T) {
    10  	cases := []struct {
    11  		a    FileInfo
    12  		b    FileInfo
    13  		want bool
    14  	}{
    15  		{a: testhelpers.NewFileInfo(
    16  			"hello.txt",
    17  			testhelpers.MustParse(time.RFC822, "02 Jan 16 11:20 GMT"),
    18  		),
    19  			b: testhelpers.NewFileInfo(
    20  				"hello.txt",
    21  				testhelpers.MustParse(time.RFC822, "02 Jan 16 11:20 GMT"),
    22  			),
    23  			want: true,
    24  		},
    25  		{a: testhelpers.NewFileInfo(
    26  			"hllo.txt",
    27  			testhelpers.MustParse(time.RFC822, "02 Jan 16 11:20 GMT"),
    28  		),
    29  			b: testhelpers.NewFileInfo(
    30  				"hello.txt",
    31  				testhelpers.MustParse(time.RFC822, "02 Jan 16 11:20 GMT"),
    32  			),
    33  			want: false,
    34  		},
    35  		{a: testhelpers.NewFileInfo(
    36  			"hello.txt",
    37  			testhelpers.MustParse(time.RFC822, "02 Jan 16 11:20 GMT"),
    38  		),
    39  			b: testhelpers.NewFileInfo(
    40  				"helo.txt",
    41  				testhelpers.MustParse(time.RFC822, "02 Jan 16 11:20 GMT"),
    42  			),
    43  			want: false,
    44  		},
    45  		{a: testhelpers.NewFileInfo(
    46  			"hello.txt",
    47  			testhelpers.MustParse(time.RFC822, "02 Jan 16 11:21 GMT"),
    48  		),
    49  			b: testhelpers.NewFileInfo(
    50  				"hello.txt",
    51  				testhelpers.MustParse(time.RFC822, "02 Jan 16 11:20 GMT"),
    52  			),
    53  			want: false,
    54  		},
    55  		{a: testhelpers.NewFileInfo(
    56  			"hello.txt",
    57  			testhelpers.MustParse(time.RFC822, "02 Jan 16 11:20 GMT"),
    58  		),
    59  			b: testhelpers.NewFileInfo(
    60  				"hello.txt",
    61  				testhelpers.MustParse(time.RFC822, "02 Jan 16 11:21 GMT"),
    62  			),
    63  			want: false,
    64  		},
    65  	}
    66  	for _, c := range cases {
    67  		if got := IsEqual(c.a, c.b); got != c.want {
    68  			t.Errorf("IsEqual(%s, %s) got: %t, want: %t", c.a, c.b, got, c.want)
    69  		}
    70  	}
    71  }