Skip to content

Commit

Permalink
add web_templates render tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krrrr38 committed Jan 15, 2023
1 parent c086b69 commit 46b0ad8
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
1 change: 0 additions & 1 deletion server/controllers/templates/web_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ type LockDetailData struct {
PullRequestLink string
LockedBy string
Workspace string
Time time.Time
AtlantisVersion string
// CleanedBasePath is the path Atlantis is accessible at externally. If
// not using a path-based proxy, this will be an empty string. Never ends
Expand Down
79 changes: 79 additions & 0 deletions server/controllers/templates/web_templates_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package templates

import (
"io"
"testing"
"time"

. "github.com/runatlantis/atlantis/testing"
)

func TestIndexTemplate(t *testing.T) {
err := IndexTemplate.Execute(io.Discard, IndexData{
Locks: []LockIndexData{
{
LockPath: "lock path",
RepoFullName: "repo full name",
PullNum: 1,
Path: "path",
Workspace: "workspace",
Time: time.Now(),
TimeFormatted: "02-01-2006 15:04:05",
},
},
ApplyLock: ApplyLockData{
Locked: true,
Time: time.Now(),
TimeFormatted: "02-01-2006 15:04:05",
},
AtlantisVersion: "v0.0.0",
CleanedBasePath: "/path",
})
Ok(t, err)
}

func TestLockTemplate(t *testing.T) {
err := LockTemplate.Execute(io.Discard, LockDetailData{
LockKeyEncoded: "lock key encoded",
LockKey: "lock key",
PullRequestLink: "https://example.com",
LockedBy: "locked by",
Workspace: "workspace",
AtlantisVersion: "v0.0.0",
CleanedBasePath: "/path",
RepoOwner: "repo owner",
RepoName: "repo name",
})
Ok(t, err)
}

func TestProjectJobsTemplate(t *testing.T) {
err := ProjectJobsTemplate.Execute(io.Discard, ProjectJobData{
AtlantisVersion: "v0.0.0",
ProjectPath: "project path",
CleanedBasePath: "/path",
})
Ok(t, err)
}

func TestProjectJobsErrorTemplate(t *testing.T) {
err := ProjectJobsTemplate.Execute(io.Discard, ProjectJobsError{
AtlantisVersion: "v0.0.0",
ProjectPath: "project path",
CleanedBasePath: "/path",
})
Ok(t, err)
}

func TestGithubAppSetupTemplate(t *testing.T) {
err := GithubAppSetupTemplate.Execute(io.Discard, GithubSetupData{
Target: "target",
Manifest: "manifest",
ID: 1,
Key: "key",
WebhookSecret: "webhook secret",
URL: "https://example.com",
CleanedBasePath: "/path",
})
Ok(t, err)
}

0 comments on commit 46b0ad8

Please sign in to comment.