api_token_test.go 549 B

1234567891011121314151617181920212223
  1. package panel
  2. import "testing"
  3. func TestApiTokenCreatedAtSeconds(t *testing.T) {
  4. tests := []struct {
  5. name string
  6. in int64
  7. want int64
  8. }{
  9. {name: "seconds", in: 1_782_485_394, want: 1_782_485_394},
  10. {name: "legacy milliseconds", in: 1_782_485_394_270, want: 1_782_485_394},
  11. {name: "unset", in: 0, want: 0},
  12. }
  13. for _, tt := range tests {
  14. t.Run(tt.name, func(t *testing.T) {
  15. if got := apiTokenCreatedAtSeconds(tt.in); got != tt.want {
  16. t.Fatalf("apiTokenCreatedAtSeconds(%d) = %d, want %d", tt.in, got, tt.want)
  17. }
  18. })
  19. }
  20. }