Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemassa committed Feb 6, 2024
1 parent b2ecf6b commit 29aea90
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 21 deletions.
8 changes: 4 additions & 4 deletions server/core/db/boltdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

var lockBucket = "bucket"
var configBucket = "configBucket"
var project = models.NewProject("owner/repo", "parent/child")
var project = models.NewProject("owner/repo", "parent/child", "")
var workspace = "default"
var pullNum = 1
var lock = models.ProjectLock{
Expand Down Expand Up @@ -155,7 +155,7 @@ func TestListMultipleLocks(t *testing.T) {

for _, r := range repos {
newLock := lock
newLock.Project = models.NewProject(r, "path")
newLock.Project = models.NewProject(r, "path", "")
_, _, err := b.TryLock(newLock)
Ok(t, err)
}
Expand Down Expand Up @@ -207,7 +207,7 @@ func TestLockingExistingLock(t *testing.T) {
t.Log("...succeed if the new project has a different path")
{
newLock := lock
newLock.Project = models.NewProject(project.RepoFullName, "different/path")
newLock.Project = models.NewProject(project.RepoFullName, "different/path", "")
acquired, currLock, err := b.TryLock(newLock)
Ok(t, err)
Equals(t, true, acquired)
Expand All @@ -227,7 +227,7 @@ func TestLockingExistingLock(t *testing.T) {
t.Log("...succeed if the new project has a different repoName")
{
newLock := lock
newLock.Project = models.NewProject("different/repo", project.Path)
newLock.Project = models.NewProject("different/repo", project.Path, "")
acquired, currLock, err := b.TryLock(newLock)
Ok(t, err)
Equals(t, true, acquired)
Expand Down
2 changes: 1 addition & 1 deletion server/core/locking/locking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
. "github.com/runatlantis/atlantis/testing"
)

var project = models.NewProject("owner/repo", "path")
var project = models.NewProject("owner/repo", "path", "")
var workspace = "workspace"
var pull = models.PullRequest{}
var user = models.User{}
Expand Down
8 changes: 4 additions & 4 deletions server/core/redis/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
. "github.com/runatlantis/atlantis/testing"
)

var project = models.NewProject("owner/repo", "parent/child")
var project = models.NewProject("owner/repo", "parent/child", "")
var workspace = "default"
var pullNum = 1
var lock = models.ProjectLock{
Expand Down Expand Up @@ -191,7 +191,7 @@ func TestListMultipleLocks(t *testing.T) {

for _, r := range repos {
newLock := lock
newLock.Project = models.NewProject(r, "path")
newLock.Project = models.NewProject(r, "path", "")
_, _, err := rdb.TryLock(newLock)
Ok(t, err)
}
Expand Down Expand Up @@ -243,7 +243,7 @@ func TestLockingExistingLock(t *testing.T) {
t.Log("...succeed if the new project has a different path")
{
newLock := lock
newLock.Project = models.NewProject(project.RepoFullName, "different/path")
newLock.Project = models.NewProject(project.RepoFullName, "different/path", "")
acquired, currLock, err := rdb.TryLock(newLock)
Ok(t, err)
Equals(t, true, acquired)
Expand All @@ -263,7 +263,7 @@ func TestLockingExistingLock(t *testing.T) {
t.Log("...succeed if the new project has a different repoName")
{
newLock := lock
newLock.Project = models.NewProject("different/repo", project.Path)
newLock.Project = models.NewProject("different/repo", project.Path, "")
acquired, currLock, err := rdb.TryLock(newLock)
Ok(t, err)
Equals(t, true, acquired)
Expand Down
3 changes: 2 additions & 1 deletion server/events/delete_lock_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestDeleteLocksByPull_SingleSuccess(t *testing.T) {
pullNum := 2
path := "."
workspace := "default"
projectName := ""
projectName := "projectname"

RegisterMockTestingT(t)
l := lockmocks.NewMockLocker()
Expand All @@ -135,6 +135,7 @@ func TestDeleteLocksByPull_SingleSuccess(t *testing.T) {
Project: models.Project{
Path: path,
RepoFullName: pull.BaseRepo.FullName,
ProjectName: projectName,
},
},
}, nil,
Expand Down
2 changes: 1 addition & 1 deletion server/events/models/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func TestNewProject(t *testing.T) {

for _, c := range cases {
t.Run(c.path, func(t *testing.T) {
p := models.NewProject("repo/owner", c.path)
p := models.NewProject("repo/owner", c.path, "")
Equals(t, c.expPath, p.Path)
})
}
Expand Down
6 changes: 5 additions & 1 deletion server/events/project_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ func (p *DefaultProjectFinder) DetermineProjects(log logging.SimpleLogging, modi
exists := p.removeNonExistingDirs(uniqueDirs, absRepoDir)

for _, p := range exists {
projects = append(projects, models.NewProject(repoFullName, p, "???????????"))
// It's unclear how we are supposed to determine the project name at this point
// For now, we'll just add the default projectName
// TODO: Add support for non-default projectName
projectName := ""
projects = append(projects, models.NewProject(repoFullName, p, projectName))
}
log.Info("there are %d modified project(s) at path(s): %v",
len(projects), strings.Join(exists, ", "))
Expand Down
18 changes: 9 additions & 9 deletions server/events/pull_closed_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestCleanUpPullComments(t *testing.T) {
"single lock, empty path",
[]models.ProjectLock{
{
Project: models.NewProject("owner/repo", ""),
Project: models.NewProject("owner/repo", "", ""),
Workspace: "default",
},
},
Expand All @@ -117,7 +117,7 @@ func TestCleanUpPullComments(t *testing.T) {
"single lock, non-empty path",
[]models.ProjectLock{
{
Project: models.NewProject("owner/repo", "path"),
Project: models.NewProject("owner/repo", "path", ""),
Workspace: "default",
},
},
Expand All @@ -127,11 +127,11 @@ func TestCleanUpPullComments(t *testing.T) {
"single path, multiple workspaces",
[]models.ProjectLock{
{
Project: models.NewProject("owner/repo", "path"),
Project: models.NewProject("owner/repo", "path", ""),
Workspace: "workspace1",
},
{
Project: models.NewProject("owner/repo", "path"),
Project: models.NewProject("owner/repo", "path", ""),
Workspace: "workspace2",
},
},
Expand All @@ -141,19 +141,19 @@ func TestCleanUpPullComments(t *testing.T) {
"multiple paths, multiple workspaces",
[]models.ProjectLock{
{
Project: models.NewProject("owner/repo", "path"),
Project: models.NewProject("owner/repo", "path", ""),
Workspace: "workspace1",
},
{
Project: models.NewProject("owner/repo", "path"),
Project: models.NewProject("owner/repo", "path", ""),
Workspace: "workspace2",
},
{
Project: models.NewProject("owner/repo", "path2"),
Project: models.NewProject("owner/repo", "path2", ""),
Workspace: "workspace1",
},
{
Project: models.NewProject("owner/repo", "path2"),
Project: models.NewProject("owner/repo", "path2", ""),
Workspace: "workspace2",
},
},
Expand Down Expand Up @@ -260,7 +260,7 @@ func TestCleanUpLogStreaming(t *testing.T) {

locks := []models.ProjectLock{
{
Project: models.NewProject(testdata.GithubRepo.FullName, ""),
Project: models.NewProject(testdata.GithubRepo.FullName, "", ""),
Workspace: "default",
},
}
Expand Down

0 comments on commit 29aea90

Please sign in to comment.