Primeiros arquivos

This commit is contained in:
2026-08-23 00:09:29 -03:00
parent 5d4b00c33a
commit 244040a479
5 changed files with 56 additions and 0 deletions

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module bot-pontos
go 1.25.0

14
internal/domain/point.go Normal file
View File

@@ -0,0 +1,14 @@
package domain
import "time"
type NotificationType string
const (
NotificationEntrada2 NotificationType = "entrada2"
NotificationSaida2 NotificationType = "saida2"
)
type Point struct {
Time time.Time
}

View File

@@ -0,0 +1,10 @@
package rules
import "time"
type BusinessDayChecker struct{}
func (b BusinessDayChecker) IsBusinessDay(t time.Time) bool {
weekday := t.Weekday()
return weekday != time.Saturday && weekday != time.Sunday
}

View File

29
tests/rules_test.go Normal file
View File

@@ -0,0 +1,29 @@
package tests
import (
"testing"
"time"
"bot-pontos/internal/rules"
)
func TestCalculosDeJornada(t *testing.T) {
loc, _ := time.LoadLocation("America/Sao_Paulo")
// Teste Entrada 2 (Saída1 + 55min)
saida1 := time.Date(2026, 8, 15, 12, 0, 0, 0, loc)
esperadoEntrada2 := time.Date(2026, 8, 15, 12, 55, 0, 0, loc)
if res := rules.CalculateEntrada2(saida1); !res.Equal(esperadoEntrada2) {
t.Errorf("Entrada2 incorreta. Esperado: %v, Obtido: %v", esperadoEntrada2, res)
}
// Teste Saída 2 (Meta 7h55)
entrada1 := time.Date(2026, 8, 15, 8, 0, 0, 0, loc)
entrada2 := time.Date(2026, 8, 15, 13, 0, 0, 0, loc)
// Trabalhou 4h de manhã. Faltam 3h55. Saída2 deve ser 16:55
esperadoSaida2 := time.Date(2026, 8, 15, 16, 55, 0, 0, loc)
if res := rules.CalculateSaida2(entrada1, saida1, entrada2); !res.Equal(esperadoSaida2) {
t.Errorf("Saida2 incorreta. Esperado: %v, Obtido: %v", esperadoSaida2, res)
}
}