File: file_test.go

package info (click to toggle)
golang-github-wellington-go-libsass 0.9.2%2Bgit20181130.4ef5b9d-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,128 kB
  • sloc: cpp: 28,607; ansic: 839; makefile: 44
file content (41 lines) | stat: -rw-r--r-- 697 bytes parent folder | download | duplicates (2)
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
package libsass

import (
	"bytes"
	"path/filepath"
	"strings"
	"testing"
)

func TestFile_resolved(t *testing.T) {
	path := "test/scss/main.scss"
	var out bytes.Buffer
	ctx := newContext()
	err := ctx.fileCompile(path, &out, "", "")
	if err != nil {
		panic(err)
	}

	e := ``

	if e != out.String() {
		t.Errorf("wanted:\n%s\n"+
			"got:\n%s\n", e, out.String())
	}

	if e := 1; len(ctx.ResolvedImports) != e {
		t.Errorf("got: %d wanted: %d", len(ctx.ResolvedImports), e)
	}

	abs, err := filepath.Abs(".")
	if err != nil {
		t.Fatal(err)
	}

	relPath := strings.TrimPrefix(ctx.ResolvedImports[0], abs)

	if !strings.HasSuffix(relPath, path) {
		t.Errorf("got: %s wanted: %s", relPath, e)
	}

}