TestSheetSuccess asserts that sheets initialize properly
(t *testing.T)
| 9 | |
| 10 | // TestSheetSuccess asserts that sheets initialize properly |
| 11 | func TestSheetSuccess(t *testing.T) { |
| 12 | |
| 13 | // initialize a sheet |
| 14 | sheet, err := New( |
| 15 | "foo", |
| 16 | "community", |
| 17 | mocks.Path("sheet/foo"), |
| 18 | []string{"alpha", "bravo"}, |
| 19 | false, |
| 20 | ) |
| 21 | if err != nil { |
| 22 | t.Errorf("failed to load sheet: %v", err) |
| 23 | } |
| 24 | |
| 25 | // assert that the sheet loaded correctly |
| 26 | if sheet.Title != "foo" { |
| 27 | t.Errorf("failed to init title: want: foo, got: %s", sheet.Title) |
| 28 | } |
| 29 | |
| 30 | if sheet.Path != mocks.Path("sheet/foo") { |
| 31 | t.Errorf( |
| 32 | "failed to init path: want: %s, got: %s", |
| 33 | mocks.Path("sheet/foo"), |
| 34 | sheet.Path, |
| 35 | ) |
| 36 | } |
| 37 | |
| 38 | wantText := "# To foo the bar:\n foo bar\n" |
| 39 | if sheet.Text != wantText { |
| 40 | t.Errorf("failed to init text: want: %s, got: %s", wantText, sheet.Text) |
| 41 | } |
| 42 | |
| 43 | // NB: tags should sort alphabetically |
| 44 | wantTags := []string{"alpha", "bar", "baz", "bravo", "foo"} |
| 45 | if !reflect.DeepEqual(sheet.Tags, wantTags) { |
| 46 | t.Errorf("failed to init tags: want: %v, got: %v", wantTags, sheet.Tags) |
| 47 | } |
| 48 | |
| 49 | if sheet.Syntax != "sh" { |
| 50 | t.Errorf("failed to init syntax: want: sh, got: %s", sheet.Syntax) |
| 51 | } |
| 52 | |
| 53 | if sheet.ReadOnly != false { |
| 54 | t.Errorf("failed to init readonly") |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | // TestSheetFailure asserts that an error is returned if the sheet cannot be |
| 59 | // read |