-
Notifications
You must be signed in to change notification settings - Fork 10
/
languages_test.go
77 lines (64 loc) · 1.76 KB
/
languages_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package gfmrun
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
var (
fakeLanguages = []byte(`
Fribble:
type: programming
color: "#FF0000"
extensions:
- .frb
ace_mode: fribble
Snarf:
type: programming
color: "#00FF00"
extensions:
- .snarf
aliases:
- snarrf
- snarrrf
ace_mode: python
group: Python
`)
)
func TestLoadLanguagesFromBytes(t *testing.T) {
langs, err := loadLanguagesFromBytes(fakeLanguages)
assert.Nil(t, err)
assert.NotNil(t, langs)
assert.Contains(t, langs.Map, "snarf")
assert.Contains(t, langs.Map, "snarrf")
assert.Contains(t, langs.Map, "snarrrf")
assert.Contains(t, langs.Map, "fribble")
}
func TestLanguages_Lookup(t *testing.T) {
langs, err := loadLanguagesFromBytes(fakeLanguages)
assert.Nil(t, err)
assert.Equal(t, "Python", langs.Lookup("snarrrf").Group)
assert.Equal(t, "Python", langs.Lookup("snarrf").Group)
assert.Equal(t, "Python", langs.Lookup("snarf").Group)
assert.Equal(t, "snarf", langs.Lookup("snarrrf").Name)
assert.Equal(t, "snarf", langs.Lookup("snarrf").Name)
assert.Equal(t, "snarf", langs.Lookup("snarf").Name)
assert.Equal(t, "fribble", langs.Lookup("fribble").AceMode)
assert.Equal(t, "fribble", langs.Lookup("fribble").Name)
assert.Nil(t, langs.Lookup("flurb"))
}
func TestLanguagesIntegration(t *testing.T) {
if !integrationTests {
t.Skip("integration tests disabled")
}
tf, err := os.CreateTemp("", "gfmrun-test")
assert.Nil(t, err)
tf.Close()
defer func() { _ = os.Remove(tf.Name()) }()
err = PullLanguagesYml("", tf.Name())
assert.Nil(t, err)
langs, err := LoadLanguages(tf.Name())
assert.Nil(t, err)
assert.Equal(t, "xquery", langs.Lookup("xquery").AceMode)
assert.Equal(t, "xml", langs.Lookup("wsdl").Name)
assert.Equal(t, "text", langs.Lookup("vbnet").AceMode)
}