-
Notifications
You must be signed in to change notification settings - Fork 32
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 #5 from smartrecruiters/master
Updated GTStructure to use pointers to items instead of value receivers
- Loading branch information
Showing
3 changed files
with
51 additions
and
15 deletions.
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
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,39 @@ | ||
package gotree | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
// TestUpdatingItemsStructure should test whenever item updates in the tree structure are | ||
// reflected correctly in the rendered structure | ||
func TestUpdatingItemsStructure(t *testing.T) { | ||
expected := "Pantera\n" + | ||
"└── Far Beyond Driven\n" + | ||
" └── 5 minutes Alone\n" | ||
|
||
var artist GTStructure | ||
artist.Name = "Pantera Typo0" | ||
|
||
var album GTStructure | ||
album.Name = "Far Beyond Driven Typo1" | ||
|
||
var music GTStructure | ||
music.Name = "5 Minutes Alone Typo2" | ||
|
||
// Add Music to the Album | ||
album.Items = append(album.Items, &music) | ||
|
||
// Add Album to the Artist | ||
artist.Items = append(artist.Items, &album) | ||
|
||
// apply updates to the items that are already in the tree structure | ||
music.Name = "5 minutes Alone" | ||
album.Name = "Far Beyond Driven" | ||
artist.Name = "Pantera" | ||
|
||
actual := StringTree(&artist) | ||
|
||
if actual != expected { | ||
t.Fatalf("Actual tree::\n[%s]\nis not the same as expected:\n[%s]", actual, expected) | ||
} | ||
} |