concept_analyser_test.go 631 字节
Newer Older
P
Phodal Huang 已提交
1 2 3
package concept

import (
P
Phodal Huang 已提交
4
	"encoding/json"
5 6
	"github.com/phodal/coca/core/models"
	"github.com/phodal/coca/core/support"
P
Phodal Huang 已提交
7
	"log"
P
Phodal Huang 已提交
8
	"path/filepath"
P
Phodal Huang 已提交
9 10 11 12 13 14 15 16 17 18
	"testing"

	. "github.com/onsi/gomega"
)

func TestConceptAnalyser_Analysis(t *testing.T) {
	g := NewGomegaWithT(t)

	var parsedDeps []models.JClassNode
	analyser := NewConceptAnalyser()
P
Phodal Huang 已提交
19 20 21 22
	codePath := "../../../_fixtures/call_api_test.json"
	codePath = filepath.FromSlash(codePath)

	file := support.ReadFile(codePath)
P
Phodal Huang 已提交
23 24 25 26 27 28 29 30 31 32
	if file == nil {
		log.Fatal("lost file")
	}

	_ = json.Unmarshal(file, &parsedDeps)

	counts := analyser.Analysis(&parsedDeps)

	g.Expect(counts.Len()).To(Equal(4))
}