Primeiros arquivos
This commit is contained in:
14
internal/domain/point.go
Normal file
14
internal/domain/point.go
Normal 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
|
||||||
|
}
|
||||||
10
internal/rules/business_day.go
Normal file
10
internal/rules/business_day.go
Normal 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
|
||||||
|
}
|
||||||
0
internal/rules/schedule_calculator.go
Normal file
0
internal/rules/schedule_calculator.go
Normal file
29
tests/rules_test.go
Normal file
29
tests/rules_test.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user