-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from bidhan-a/issue-29
Remove deleted pipelines from global active pipeline list
- Loading branch information
Showing
3 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package pipeline | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/gaia-pipeline/gaia" | ||
) | ||
|
||
func TestRemove(t *testing.T) { | ||
ap := NewActivePipelines() | ||
|
||
p1 := gaia.Pipeline{ | ||
Name: "Pipeline A", | ||
Type: gaia.PTypeGolang, | ||
Created: time.Now(), | ||
} | ||
ap.Append(p1) | ||
|
||
p2 := gaia.Pipeline{ | ||
Name: "Pipeline B", | ||
Type: gaia.PTypeGolang, | ||
Created: time.Now(), | ||
} | ||
ap.Append(p2) | ||
|
||
ap.Remove(1) | ||
|
||
count := 0 | ||
for pipeline := range ap.Iter() { | ||
count++ | ||
if pipeline.Name == "Pipeline B" { | ||
t.Fatalf("Pipeline B still exists. It should have been removed.") | ||
} | ||
} | ||
|
||
if count != 1 { | ||
t.Fatalf("Expected pipeline count to be %v. Got %v.", 1, count) | ||
} | ||
} | ||
|
||
func TestRemoveDeletedPipelines(t *testing.T) { | ||
ap := NewActivePipelines() | ||
|
||
p1 := gaia.Pipeline{ | ||
Name: "Pipeline A", | ||
Type: gaia.PTypeGolang, | ||
Created: time.Now(), | ||
} | ||
ap.Append(p1) | ||
|
||
p2 := gaia.Pipeline{ | ||
Name: "Pipeline B", | ||
Type: gaia.PTypeGolang, | ||
Created: time.Now(), | ||
} | ||
ap.Append(p2) | ||
|
||
p3 := gaia.Pipeline{ | ||
Name: "Pipeline C", | ||
Type: gaia.PTypeGolang, | ||
Created: time.Now(), | ||
} | ||
ap.Append(p3) | ||
|
||
// Let's assume Pipeline B was deleted. | ||
existingPipelineNames := []string{"Pipeline A", "Pipeline C"} | ||
|
||
ap.RemoveDeletedPipelines(existingPipelineNames) | ||
|
||
for pipeline := range ap.Iter() { | ||
if pipeline.Name == "Pipeline B" { | ||
t.Fatalf("Pipeline B still exists. It should have been removed.") | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters