From fef9032fe40308cfbb367bf0969499e8d03206b3 Mon Sep 17 00:00:00 2001 From: asoseil Date: Wed, 22 Nov 2017 17:23:41 +0100 Subject: [PATCH] setup test --- realize/projects.go | 3 +-- realize/projects_test.go | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/realize/projects.go b/realize/projects.go index 7214eb1..b91d9cd 100644 --- a/realize/projects.go +++ b/realize/projects.go @@ -47,7 +47,6 @@ type Project struct { init bool files int64 folders int64 - name string lastFile string paths []string lastTime time.Time @@ -96,7 +95,7 @@ type ProjectI interface { // Setup a project func (p *Project) Setup() { // get base path - p.name = filepath.Base(p.Path) + p.Name = filepath.Base(p.Path) // set env const for key, item := range p.Environment { if err := os.Setenv(key, item); err != nil { diff --git a/realize/projects_test.go b/realize/projects_test.go index 4b7b005..2cb1c30 100644 --- a/realize/projects_test.go +++ b/realize/projects_test.go @@ -1 +1,23 @@ package realize + +import ( + "testing" + "os" +) + +func TestProject_Setup(t *testing.T) { + input := "Rtest" + p := Project{ + Path: "/test/prova/"+input, + Environment: map[string]string{ + input: input, + }, + } + p.Setup() + if p.Name != input{ + t.Error("Unexpected error", p.Name,"instead",input) + } + if os.Getenv(input) != input{ + t.Error("Unexpected error", os.Getenv(input),"instead",input) + } +} \ No newline at end of file