Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started work on implmenting interface for status crud ops on filesystem
Now that the core has the interface for CRUD operations, I'm implementing the interface in the CLI. The implementation in the CLI will work with the statuses.yaml file to carry out the crud operations. Someday I might write an implementation to deal with sqlite based storage but today is not that day
- Loading branch information
1 parent
603704a
commit cb2b9c7
Showing
2 changed files
with
49 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/kiriappeee/slack-status-updater-core" | ||
) | ||
|
||
type statusCRUDFileImplementation string | ||
|
||
func (s statusCRUDFileImplementation) GetStatuses() []ssucore.Status { | ||
return []ssucore.Status{ | ||
ssucore.Status{"test", "emojiA", "Status One"}, | ||
ssucore.Status{"test1", "emojiB", "Status Two"}, | ||
ssucore.Status{"test2", "emojiC", "Status Three"}, | ||
ssucore.Status{"test3", "emojiD", "Status Four"}, | ||
} | ||
} | ||
|
||
func (s statusCRUDFileImplementation) GetStatusByKey(name string) (ssucore.Status, error) { | ||
//stub | ||
return ssucore.Status{}, nil | ||
} | ||
|
||
func (s statusCRUDFileImplementation) AddNewStatus(status ssucore.Status) error { | ||
//stub | ||
return nil | ||
} | ||
|
||
func (s statusCRUDFileImplementation) DeleteStatusByName(name string) error { | ||
//stub | ||
return nil | ||
} |
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,18 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/kiriappeee/slack-status-updater-core" | ||
) | ||
|
||
func TestStatusesCanBeListed(t *testing.T) { | ||
var sci ssucore.StatusCRUDInterface | ||
homeDirectory := os.Getenv("HOME") | ||
sci = statusCRUDFileImplementation(homeDirectory + "/.config/ssuclitest/statuses.yaml") | ||
statuses := ssucore.GetStatuses(sci) | ||
if len(statuses) != 4 { | ||
t.Fatalf("Did not receive the expected statuses") | ||
} | ||
} |