13 Commits

Author SHA1 Message Date
8df89d3478 schedule looks good now, run at 20 utc, so 21 cest.
All checks were successful
Run short tests / run-tests (push) Successful in 1m15s
Run nightly tests / nightly-tests (push) Successful in 1m50s
2025-05-21 14:51:24 +02:00
f97841b079 print working see with checkout
All checks were successful
Run short tests / run-tests (push) Successful in 1m14s
Run nightly tests / nightly-tests (push) Successful in 1m40s
2025-05-21 14:41:44 +02:00
17d2f4d1f5 test cron
All checks were successful
Run short tests / run-tests (push) Successful in 1m15s
Run nightly tests / test-cron-job (push) Successful in 30s
2025-05-21 14:38:05 +02:00
1aa6c7dac4 test cron at 1430
All checks were successful
Run short tests / run-tests (push) Successful in 1m14s
Run nightly tests / run-tests (push) Successful in 1m41s
2025-05-21 14:24:22 +02:00
da5bf43197 add push to main
All checks were successful
Run short tests / run-tests (push) Successful in 1m14s
Run nightly tests / run-tests (push) Successful in 1m40s
2025-05-21 10:52:29 +02:00
0d803f4b23 add nightly cron at 0am
All checks were successful
Run short tests / run-tests (push) Successful in 1m38s
2025-05-20 15:22:30 +02:00
fc4e0217b2 check if lable works
All checks were successful
Run short tests / run-tests (push) Successful in 1m13s
Run nightly tests / run-tests (push) Successful in 1m36s
2025-05-20 15:20:07 +02:00
d4db20be16 add nightly test template
Some checks failed
Run nightly tests / run-tests (push) Failing after 13s
Run short tests / run-tests (push) Has been cancelled
2025-05-20 15:19:16 +02:00
1041016210 Revert "change runner to linux"
Some checks failed
Run short tests / run-tests (push) Has been cancelled
This reverts commit 99ed529600.
2025-05-20 15:18:18 +02:00
99ed529600 change runner to linux
Some checks failed
Run short tests / run-tests (push) Failing after 12s
2025-05-20 15:16:58 +02:00
f02bb1e6fb Merge pull request 'feature/refactoring' (#1) from feature/refactoring into master
All checks were successful
Run short tests / run-tests (push) Successful in 1m58s
Reviewed-on: https://code.jamesvillage.dev/tliu93/home-automation-backend/pulls/1
2025-05-19 22:28:40 +02:00
ccb70e3165 Use struct, idomatic go way to write homeassistant component and make it 100 test covered
All checks were successful
Run short tests / run-tests (push) Successful in 1m2s
Run short tests / run-tests (pull_request) Successful in 1m2s
2025-05-19 22:20:05 +02:00
0a76c5feca wip 2025-05-19 20:25:53 +02:00
7 changed files with 142 additions and 117 deletions

22
.github/workflows/nightly.yml vendored Normal file
View File

@@ -0,0 +1,22 @@
name: Run nightly tests
on:
schedule:
- cron: '0 20 * * *' # Every day at 20:00 UTC
push:
branches:
- main
jobs:
nightly-tests:
runs-on: [ubuntu-latest, cloud]
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Test
working-directory: ./src
run: go test -v --short ./...

View File

@@ -27,7 +27,8 @@ import (
var (
port string
scheduler gocron.Scheduler
ticktick *ticktickutil.TicktickUtilImpl
ticktick ticktickutil.TicktickUtil
ha *homeassistant.HomeAssistant
)
// serveCmd represents the serve command
@@ -55,7 +56,7 @@ func initComponent() {
// init location recorder
locationRecorder.Init()
// init homeassistant
homeassistant.Init(ticktick)
ha = homeassistant.NewHomeAssistant(ticktick)
}
func serve(cmd *cobra.Command, args []string) {
@@ -108,7 +109,7 @@ func serve(cmd *cobra.Command, args []string) {
router.HandleFunc("/poo/latest", pooRecorder.HandleNotifyLatestPoo).Methods("GET")
router.HandleFunc("/poo/record", pooRecorder.HandleRecordPoo).Methods("POST")
router.HandleFunc("/homeassistant/publish", homeassistant.HandleHaMessage).Methods("POST")
router.HandleFunc("/homeassistant/publish", ha.HandleHaMessage).Methods("POST")
router.HandleFunc("/location/record", locationRecorder.HandleRecordLocation).Methods("POST")

View File

@@ -18,63 +18,68 @@ type haMessage struct {
Content string `json:"content"`
}
type HomeAssistant struct {
ticktickUtil ticktickutil.TicktickUtil
}
type actionTask struct {
Action string `json:"action"`
DueHour int `json:"due_hour"`
}
var (
ticktickUtil ticktickutil.TicktickUtil
)
func Init(ticktick ticktickutil.TicktickUtil) {
ticktickUtil = ticktick
func NewHomeAssistant(ticktick ticktickutil.TicktickUtil) *HomeAssistant {
return &HomeAssistant{
ticktickUtil: ticktick,
}
}
func HandleHaMessage(w http.ResponseWriter, r *http.Request) {
func (ha *HomeAssistant) HandleHaMessage(w http.ResponseWriter, r *http.Request) {
var message haMessage
decoder := json.NewDecoder(r.Body)
decoder.DisallowUnknownFields()
err := decoder.Decode(&message)
if err != nil {
slog.Warn(fmt.Sprintln("HandleHaMessage: Error decoding request body", err))
http.Error(w, err.Error(), http.StatusBadRequest)
slog.Warn(fmt.Sprintln("homeassistant.HandleHaMessage: Error decoding request body", err))
http.Error(w, "", http.StatusInternalServerError)
return
}
switch message.Target {
case "poo_recorder":
res := handlePooRecorderMsg(message)
res := ha.handlePooRecorderMsg(message)
if !res {
http.Error(w, "Error handling poo recorder message", http.StatusInternalServerError)
slog.Warn(fmt.Sprintln("homeassistant.HandleHaMessage: Error handling poo recorder message"))
http.Error(w, "", http.StatusInternalServerError)
}
case "location_recorder":
res := handleLocationRecorderMsg(message)
res := ha.handleLocationRecorderMsg(message)
if !res {
http.Error(w, "Error handling location recorder message", http.StatusInternalServerError)
slog.Warn(fmt.Sprintln("homeassistant.HandleHaMessage: Error handling location recorder message"))
http.Error(w, "", http.StatusInternalServerError)
}
case "ticktick":
res := handleTicktickMsg(message)
res := ha.handleTicktickMsg(message)
if !res {
http.Error(w, "Error handling ticktick message", http.StatusInternalServerError)
slog.Warn(fmt.Sprintln("homeassistant.HandleHaMessage: Error handling ticktick message"))
http.Error(w, "", http.StatusInternalServerError)
}
default:
slog.Warn(fmt.Sprintln("HandleHaMessage: Unknown target", message.Target))
http.Error(w, "Unknown target", http.StatusBadRequest)
slog.Warn(fmt.Sprintln("homeassistant.HandleHaMessage: Unknown target", message.Target))
http.Error(w, "", http.StatusInternalServerError)
}
}
func handlePooRecorderMsg(message haMessage) bool {
func (ha *HomeAssistant) handlePooRecorderMsg(message haMessage) bool {
switch message.Action {
case "get_latest":
return handleGetLatestPoo()
return ha.handleGetLatestPoo()
default:
slog.Warn(fmt.Sprintln("handlePooRecorderMsg: Unknown action", message.Action))
slog.Warn(fmt.Sprintln("homeassistant.handlePooRecorderMsg: Unknown action", message.Action))
return false
}
}
func handleLocationRecorderMsg(message haMessage) bool {
func (ha *HomeAssistant) handleLocationRecorderMsg(message haMessage) bool {
if message.Action == "record" {
port := viper.GetString("port")
client := &http.Client{
@@ -82,43 +87,43 @@ func handleLocationRecorderMsg(message haMessage) bool {
}
_, err := client.Post("http://localhost:"+port+"/location/record", "application/json", strings.NewReader(strings.ReplaceAll(message.Content, "'", "\"")))
if err != nil {
slog.Warn(fmt.Sprintln("handleLocationRecorderMsg: Error sending request to location recorder", err))
slog.Warn(fmt.Sprintln("homeassistant.handleLocationRecorderMsg: Error sending request to location recorder", err))
return false
}
return true
} else {
slog.Warn(fmt.Sprintln("handleLocationRecorderMsg: Unknown action", message.Action))
slog.Warn(fmt.Sprintln("homeassistant.handleLocationRecorderMsg: Unknown action", message.Action))
return false
}
return true
}
func handleTicktickMsg(message haMessage) bool {
func (ha *HomeAssistant) handleTicktickMsg(message haMessage) bool {
switch message.Action {
case "create_action_task":
return createActionTask(message)
return ha.createActionTask(message)
default:
slog.Warn(fmt.Sprintln("handleTicktickMsg: Unknown action", message.Action))
slog.Warn(fmt.Sprintln("homeassistant.handleTicktickMsg: Unknown action", message.Action))
return false
}
}
func handleGetLatestPoo() bool {
func (ha *HomeAssistant) handleGetLatestPoo() bool {
client := &http.Client{
Timeout: time.Second * 1,
}
port := viper.GetString("port")
_, err := client.Get("http://localhost:" + port + "/poo/latest")
if err != nil {
slog.Warn(fmt.Sprintln("handleGetLatestPoo: Error sending request to poo recorder", err))
slog.Warn(fmt.Sprintln("homeassistant.handleGetLatestPoo: Error sending request to poo recorder", err))
return false
}
return true
}
func createActionTask(message haMessage) bool {
func (ha *HomeAssistant) createActionTask(message haMessage) bool {
if !viper.IsSet("homeassistant.actionTaskProjectId") {
slog.Warn("Homeassistant.createActionTask actionTaskProjectId not set")
slog.Warn("homeassistant.createActionTask: actionTaskProjectId not found in config file")
return false
}
projectId := viper.GetString("homeassistant.actionTaskProjectId")
@@ -126,7 +131,7 @@ func createActionTask(message haMessage) bool {
var task actionTask
err := json.Unmarshal([]byte(detail), &task)
if err != nil {
slog.Warn(fmt.Sprintln("Homeassistant.createActionTask: Error unmarshalling", err))
slog.Warn(fmt.Sprintln("homeassistant.createActionTask: Error unmarshalling", err))
return false
}
dueHour := task.DueHour
@@ -138,9 +143,9 @@ func createActionTask(message haMessage) bool {
Title: task.Action,
DueDate: dueTicktick,
}
err = ticktickUtil.CreateTask(ticktickTask)
err = ha.ticktickUtil.CreateTask(ticktickTask)
if err != nil {
slog.Warn(fmt.Sprintf("Homeassistant.createActionTask: Error creating task %s", err))
slog.Warn(fmt.Sprintf("homeassistant.createActionTask: Error creating task %s", err))
return false
}
return true

View File

@@ -20,19 +20,38 @@ var (
loggerText = new(bytes.Buffer)
)
type (
MockedTicktickUtil struct {
mock.Mock
}
)
type MockTicktickUtil struct {
mock.Mock
}
func SetupTearDown(t *testing.T) func() {
func (m *MockTicktickUtil) HandleAuthCode(w http.ResponseWriter, r *http.Request) {
m.Called(w, r)
}
func (m *MockTicktickUtil) GetTasks(projectId string) []ticktickutil.Task {
args := m.Called(projectId)
return args.Get(0).([]ticktickutil.Task)
}
func (m *MockTicktickUtil) HasDuplicateTask(projectId string, taskTitile string) bool {
args := m.Called(projectId, taskTitile)
return args.Bool(0)
}
func (m *MockTicktickUtil) CreateTask(task ticktickutil.Task) error {
args := m.Called(task)
return args.Error(0)
}
func SetupTearDown(t *testing.T) (func(), *HomeAssistant) {
loggertearDown := loggerSetupTeardown()
mockTicktick := &MockTicktickUtil{}
ha := NewHomeAssistant(mockTicktick)
return func() {
loggertearDown()
viper.Reset()
}
}, ha
}
func loggerSetupTeardown() func() {
@@ -46,40 +65,21 @@ func loggerSetupTeardown() func() {
}
}
func (m *MockedTicktickUtil) HandleAuthCode(w http.ResponseWriter, r *http.Request) {
m.Called(w, r)
}
func (m *MockedTicktickUtil) GetTasks(projectId string) []ticktickutil.Task {
args := m.Called(projectId)
return args.Get(0).([]ticktickutil.Task)
}
func (m *MockedTicktickUtil) HasDuplicateTask(projectId string, taskTitile string) bool {
args := m.Called(projectId, taskTitile)
return args.Bool(0)
}
func (m *MockedTicktickUtil) CreateTask(task ticktickutil.Task) error {
args := m.Called(task)
return args.Error(0)
}
func TestHandleHaMessageJsonDecodeError(t *testing.T) {
teardown := SetupTearDown(t)
teardown, ha := SetupTearDown(t)
defer teardown()
invalidRequestBody := ` { "target": "poo_recorder", "action": "get_latest", "content": " }`
req := httptest.NewRequest(http.MethodPost, "/homeassistant/publish", strings.NewReader(invalidRequestBody))
w := httptest.NewRecorder()
HandleHaMessage(w, req)
assert.Equal(t, http.StatusBadRequest, w.Code)
assert.Contains(t, loggerText.String(), "HandleHaMessage: Error decoding request body")
ha.HandleHaMessage(w, req)
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Contains(t, loggerText.String(), "homeassistant.HandleHaMessage: Error decoding request body")
}
func TestHandlePooRecorderMsgGetLatest(t *testing.T) {
teardown := SetupTearDown(t)
teardown, ha := SetupTearDown(t)
defer teardown()
requestBody := `{"target": "poo_recorder", "action": "get_latest", "content": ""}`
req := httptest.NewRequest(http.MethodPost, "/homeassistant/publish", strings.NewReader(requestBody))
@@ -92,26 +92,26 @@ func TestHandlePooRecorderMsgGetLatest(t *testing.T) {
port := strings.Split(server.URL, ":")[2]
viper.Set("port", port)
HandleHaMessage(w, req)
ha.HandleHaMessage(w, req)
assert.Equal(t, http.StatusOK, w.Code)
assert.Empty(t, loggerText.String())
}
func TestHandlePooRecorderMsgUnknownAction(t *testing.T) {
teardown := SetupTearDown(t)
teardown, ha := SetupTearDown(t)
defer teardown()
requestBody := `{"target": "poo_recorder", "action": "unknown_action", "content": ""}`
req := httptest.NewRequest(http.MethodPost, "/homeassistant/publish", strings.NewReader(requestBody))
w := httptest.NewRecorder()
HandleHaMessage(w, req)
ha.HandleHaMessage(w, req)
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Contains(t, loggerText.String(), "handlePooRecorderMsg: Unknown action")
assert.Contains(t, loggerText.String(), "homeassistant.handlePooRecorderMsg: Unknown action")
}
func TestHandlePooRecorderMsgGetLatestError(t *testing.T) {
teardown := SetupTearDown(t)
teardown, ha := SetupTearDown(t)
defer teardown()
requestBody := `{"target": "poo_recorder", "action": "get_latest", "content": ""}`
@@ -121,13 +121,13 @@ func TestHandlePooRecorderMsgGetLatestError(t *testing.T) {
port := "invalid port"
viper.Set("port", port)
HandleHaMessage(w, req)
ha.HandleHaMessage(w, req)
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Contains(t, loggerText.String(), "handleGetLatestPoo: Error sending request to poo recorder")
assert.Contains(t, loggerText.String(), "homeassistant.handleGetLatestPoo: Error sending request to poo recorder")
}
func TestHandleLocationRecorderMsg(t *testing.T) {
teardown := SetupTearDown(t)
teardown, ha := SetupTearDown(t)
defer teardown()
requestBody := `{"target": "location_recorder", "action": "record", "content": "{'person': 'test', 'latitude': '1.0', 'longitude': '2.0', 'altitude': '3.0'}"}`
@@ -143,26 +143,26 @@ func TestHandleLocationRecorderMsg(t *testing.T) {
port := strings.Split(server.URL, ":")[2]
viper.Set("port", port)
HandleHaMessage(w, req)
ha.HandleHaMessage(w, req)
assert.Equal(t, http.StatusOK, w.Code)
assert.Empty(t, loggerText.String())
}
func TestHandleLocationRecorderMsgUnknownAction(t *testing.T) {
teardown := SetupTearDown(t)
teardown, ha := SetupTearDown(t)
defer teardown()
requestBody := `{"target": "location_recorder", "action": "unknown_action", "content": ""}`
req := httptest.NewRequest(http.MethodPost, "/homeassistant/publish", strings.NewReader(requestBody))
w := httptest.NewRecorder()
HandleHaMessage(w, req)
ha.HandleHaMessage(w, req)
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Contains(t, loggerText.String(), "handleLocationRecorderMsg: Unknown action")
assert.Contains(t, loggerText.String(), "homeassistant.handleLocationRecorderMsg: Unknown action")
}
func TestHandleLocationRecorderMsgRequestErr(t *testing.T) {
teardown := SetupTearDown(t)
teardown, ha := SetupTearDown(t)
defer teardown()
requestBody := `{"target": "location_recorder", "action": "record", "content": "{'person': 'test', 'latitude': '1.0', 'longitude': '2.0', 'altitude': '3.0'}"}`
@@ -172,13 +172,13 @@ func TestHandleLocationRecorderMsgRequestErr(t *testing.T) {
port := "invalid port"
viper.Set("port", port)
HandleHaMessage(w, req)
ha.HandleHaMessage(w, req)
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Contains(t, loggerText.String(), "handleLocationRecorderMsg: Error sending request to location recorder")
assert.Contains(t, loggerText.String(), "homeassistant.handleLocationRecorderMsg: Error sending request to location recorder")
}
func TestHandleTicktickMsgCreateActionTask(t *testing.T) {
teardown := SetupTearDown(t)
teardown, _ := SetupTearDown(t)
defer teardown()
const expectedProjectId = "test_project_id"
const dueHour = 12
@@ -189,96 +189,92 @@ func TestHandleTicktickMsgCreateActionTask(t *testing.T) {
requestBody := `{"target": "ticktick", "action": "create_action_task", "content": "{'title': 'test', 'action': 'test_action', 'due_hour': 12}"}`
req := httptest.NewRequest(http.MethodPost, "/homeassistant/publish", strings.NewReader(requestBody))
w := httptest.NewRecorder()
mockedTicktickUtil := new(MockedTicktickUtil)
mockTicktick := &MockTicktickUtil{}
mockTicktick.On("CreateTask", mock.Anything).Return(nil)
ha := NewHomeAssistant(mockTicktick)
viper.Set("homeassistant.actionTaskProjectId", expectedProjectId)
mockedTicktickUtil.On("CreateTask", mock.Anything).Return(nil)
Init(mockedTicktickUtil)
HandleHaMessage(w, req)
ha.HandleHaMessage(w, req)
expectedTask := ticktickutil.Task{
Title: "test_action",
ProjectId: expectedProjectId,
DueDate: dueTicktick,
ProjectId: expectedProjectId,
}
mockedTicktickUtil.AssertCalled(t, "CreateTask", expectedTask)
mockedTicktickUtil.AssertNumberOfCalls(t, "CreateTask", 1)
mockTicktick.AssertCalled(t, "CreateTask", expectedTask)
mockTicktick.AssertNumberOfCalls(t, "CreateTask", 1)
assert.Equal(t, http.StatusOK, w.Code)
assert.Empty(t, loggerText.String())
}
func TestHandleTicktickMsgUnknownAction(t *testing.T) {
teardown := SetupTearDown(t)
teardown, ha := SetupTearDown(t)
defer teardown()
requestBody := `{"target": "ticktick", "action": "unknown_action", "content": ""}`
req := httptest.NewRequest(http.MethodPost, "/homeassistant/publish", strings.NewReader(requestBody))
w := httptest.NewRecorder()
HandleHaMessage(w, req)
ha.HandleHaMessage(w, req)
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Contains(t, loggerText.String(), "handleTicktickMsg: Unknown action")
assert.Contains(t, loggerText.String(), "homeassistant.handleTicktickMsg: Unknown action")
}
func TestHandleTicktickMsgProjectIdUnset(t *testing.T) {
teardown := SetupTearDown(t)
teardown, ha := SetupTearDown(t)
defer teardown()
requestBody := `{"target": "ticktick", "action": "create_action_task", "content": "{'title': 'test', 'action': 'test_action', 'due_hour': 12}"}`
req := httptest.NewRequest(http.MethodPost, "/homeassistant/publish", strings.NewReader(requestBody))
w := httptest.NewRecorder()
HandleHaMessage(w, req)
ha.HandleHaMessage(w, req)
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Contains(t, loggerText.String(), "Homeassistant.createActionTask actionTaskProjectId not set")
assert.Contains(t, loggerText.String(), "homeassistant.createActionTask: actionTaskProjectId not found in config file")
}
func TestHandleTicktickMsgJsonError(t *testing.T) {
teardown := SetupTearDown(t)
teardown, ha := SetupTearDown(t)
defer teardown()
invalidRequestBody := ` { "target": "ticktick", "action": "create_action_task", "content": "{'title': 'tes, 'action': 'test_action', 'due_hour': 12}"}`
req := httptest.NewRequest(http.MethodPost, "/homeassistant/publish", strings.NewReader(invalidRequestBody))
w := httptest.NewRecorder()
viper.Set("homeassistant.actionTaskProjectId", "some project id")
HandleHaMessage(w, req)
ha.HandleHaMessage(w, req)
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Contains(t, loggerText.String(), "Homeassistant.createActionTask: Error unmarshalling")
assert.Contains(t, loggerText.String(), "homeassistant.createActionTask: Error unmarshalling")
}
func TestHandleTicktickMsgTicktickUtilErr(t *testing.T) {
teardown := SetupTearDown(t)
teardown, _ := SetupTearDown(t)
defer teardown()
requestBody := `{"target": "ticktick", "action": "create_action_task", "content": "{'title': 'test', 'action': 'test_action', 'due_hour': 12}"}`
req := httptest.NewRequest(http.MethodPost, "/homeassistant/publish", strings.NewReader(requestBody))
w := httptest.NewRecorder()
mockedTicktickUtil := new(MockedTicktickUtil)
mockedTicktickUtil := &MockTicktickUtil{}
viper.Set("homeassistant.actionTaskProjectId", "some project id")
mockedTicktickUtil.On("CreateTask", mock.Anything).Return(errors.New("some error"))
Init(mockedTicktickUtil)
ha := NewHomeAssistant(mockedTicktickUtil)
HandleHaMessage(w, req)
ha.HandleHaMessage(w, req)
mockedTicktickUtil.AssertCalled(t, "CreateTask", mock.Anything)
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Contains(t, loggerText.String(), "Homeassistant.createActionTask: Error creating task")
assert.Contains(t, loggerText.String(), "homeassistant.createActionTask: Error creating task")
}
func TestHandleHaMessageUnknownTarget(t *testing.T) {
teardown := SetupTearDown(t)
teardown, ha := SetupTearDown(t)
defer teardown()
requestBody := `{"target": "unknown_target", "action": "record", "content": ""}`
req := httptest.NewRequest(http.MethodPost, "/homeassistant/publish", strings.NewReader(requestBody))
w := httptest.NewRecorder()
HandleHaMessage(w, req)
assert.Equal(t, http.StatusBadRequest, w.Code)
assert.Contains(t, loggerText.String(), "HandleHaMessage: Unknown target")
ha.HandleHaMessage(w, req)
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Contains(t, loggerText.String(), "homeassistant.HandleHaMessage: Unknown target")
}

View File

@@ -8,7 +8,7 @@ require (
github.com/jomei/notionapi v1.13.2
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
golang.org/x/term v0.24.0
modernc.org/sqlite v1.33.1
)

View File

@@ -78,8 +78,9 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=

View File

@@ -78,7 +78,7 @@ type (
}
)
func Init() *TicktickUtilImpl { // TODO: Will modify Init to a proper behavior
func Init() TicktickUtil { // TODO: Will modify Init to a proper behavior
ticktickUtilImpl := &TicktickUtilImpl{}
if !viper.InConfig("ticktick.clientId") {
slog.Error("TickTick clientId not found in config file, exiting..")