feat: updated docs and added description to files
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
// Helper package to create audit logs in the logs folder
|
||||
// these are by the time only generated, when a booking is
|
||||
// changed on the /time page
|
||||
package logs
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// this package contains different functions to parse URL.Values or Form.Values
|
||||
// into other datatypes see functionname
|
||||
// on fail the funktions either return a fallback or error
|
||||
|
||||
package paramParser
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package helper
|
||||
|
||||
func GetFirst[T, U any](val T, _ U) T {
|
||||
return val
|
||||
}
|
||||
|
||||
func GetSecond[T, U any](_ T, val U) U {
|
||||
return val
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package helper
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGetFirst(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
a any
|
||||
b any
|
||||
want any
|
||||
}{
|
||||
{"ints", 10, 20, 10},
|
||||
{"strings", "first", "second", "first"},
|
||||
{"mixed", "abc", 123, "abc"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := GetFirst(tt.a, tt.b)
|
||||
if got != tt.want {
|
||||
t.Errorf("GetFirst(%v, %v) = %v, want %v", tt.a, tt.b, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSecond(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
a any
|
||||
b any
|
||||
want any
|
||||
}{
|
||||
{"ints", 10, 20, 20},
|
||||
{"strings", "first", "second", "second"},
|
||||
{"mixed", "abc", 123, 123},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := GetSecond(tt.a, tt.b)
|
||||
if got != tt.want {
|
||||
t.Errorf("GetSecond(%v, %v) = %v, want %v", tt.a, tt.b, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package helper
|
||||
|
||||
// different system helpers for environment variables + cache
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package helper
|
||||
|
||||
// time helpers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
@@ -27,11 +29,6 @@ func IsWeekend(ts time.Time) bool {
|
||||
return ts.Weekday() == time.Saturday || ts.Weekday() == time.Sunday
|
||||
}
|
||||
|
||||
func GetKW(t time.Time) int {
|
||||
_, kw := t.ISOWeek()
|
||||
return kw
|
||||
}
|
||||
|
||||
func FormatDuration(d time.Duration) string {
|
||||
return FormatDurationFill(d, false)
|
||||
}
|
||||
|
||||
@@ -132,41 +132,3 @@ func TestFormatGermanDayOfWeek(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetKW(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
date time.Time
|
||||
want int
|
||||
}{
|
||||
{
|
||||
name: "First week of year",
|
||||
date: time.Date(2023, 1, 2, 0, 0, 0, 0, time.UTC), // Monday
|
||||
want: 1,
|
||||
},
|
||||
{
|
||||
name: "Middle of year",
|
||||
date: time.Date(2023, 6, 15, 0, 0, 0, 0, time.UTC),
|
||||
want: 24,
|
||||
},
|
||||
{
|
||||
name: "Last week of year",
|
||||
date: time.Date(2023, 12, 31, 0, 0, 0, 0, time.UTC),
|
||||
want: 52,
|
||||
},
|
||||
{
|
||||
name: "ISO week crossing into next year",
|
||||
date: time.Date(2020, 12, 31, 0, 0, 0, 0, time.UTC),
|
||||
want: 53,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := GetKW(tt.date)
|
||||
if got != tt.want {
|
||||
t.Errorf("GetKW(%v) = %d, want %d", tt.date, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
package helper
|
||||
|
||||
import "time"
|
||||
|
||||
type TimeFormValue struct {
|
||||
TsFrom time.Time
|
||||
TsTo time.Time
|
||||
CardUID string
|
||||
}
|
||||
// type conversion
|
||||
|
||||
func BoolToInt(b bool) int {
|
||||
var i int = 0
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package helper
|
||||
|
||||
// web helpers to either set Cross Origin Request Security or block all requests without a user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
Reference in New Issue
Block a user