Files
arbeitszeitmessung/Backend/models/booking_test.go
Tom Tröger f21ce9a3c3
All checks were successful
Tests / Run Go Tests (push) Successful in 1m44s
fixed: pause time calculation from work instead of presence time
2026-02-24 20:05:08 +01:00

263 lines
6.2 KiB
Go

package models_test
import (
"arbeitszeitmessung/models"
"time"
)
var testBookingType = models.BookingType{
Id: 1,
Name: "Büro",
}
var testBookings8hrs = []models.Booking{{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType,
}, {
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 16, 0, 0, 0, time.UTC),
BookingType: testBookingType,
}}
var testBookings6hrs = []models.Booking{{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType,
}, {
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 14, 0, 0, 0, time.UTC),
BookingType: testBookingType,
}}
var testBookings10hrs = []models.Booking{{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType,
}, {
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 18, 0, 0, 0, time.UTC),
BookingType: testBookingType,
}}
var testBookings6hrsBreak30min = []models.Booking{
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 9, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 9, 30, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 14, 30, 0, 0, time.UTC),
BookingType: testBookingType,
}}
var testBookings610hrsBreak30min = []models.Booking{
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 9, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 9, 30, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 14, 40, 0, 0, time.UTC),
BookingType: testBookingType,
}}
var testBookings9hrsBreak30min = []models.Booking{
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 9, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 9, 30, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 17, 30, 0, 0, time.UTC),
BookingType: testBookingType,
}}
var testBookings930hrs = []models.Booking{
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 17, 30, 0, 0, time.UTC),
BookingType: testBookingType,
}}
var testBookings910hrsBreak30min = []models.Booking{
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 9, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 9, 30, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 17, 40, 0, 0, time.UTC),
BookingType: testBookingType,
},
}
var testBookings910hrsBreak35min = []models.Booking{
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 9, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 9, 35, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 17, 45, 0, 0, time.UTC),
BookingType: testBookingType,
},
}
var testBookings945hrs = []models.Booking{
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 17, 45, 0, 0, time.UTC),
BookingType: testBookingType,
},
}
var testBookings10hrsBreak45min = []models.Booking{
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 9, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 9, 45, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 18, 00, 0, 0, time.UTC),
BookingType: testBookingType,
},
}
var testBookings1030hrsBreak45min = []models.Booking{
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 8, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 9, 0, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 1,
Timestamp: time.Date(2025, 01, 01, 9, 45, 0, 0, time.UTC),
BookingType: testBookingType,
},
{
CardUID: "aaaa-aaaa",
CheckInOut: 2,
Timestamp: time.Date(2025, 01, 01, 18, 30, 0, 0, time.UTC),
BookingType: testBookingType,
},
}