MCPcopy
hub / github.com/cilium/cilium / Test_fmtTimestamp

Function Test_fmtTimestamp

hubble/pkg/printer/printer_test.go:794–850  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

792}
793
794func Test_fmtTimestamp(t *testing.T) {
795 type args struct {
796 layout string
797 t *timestamppb.Timestamp
798 }
799 tests := []struct {
800 name string
801 args args
802 want string
803 }{
804 {
805 name: "valid",
806 args: args{
807 layout: time.StampMilli,
808 t: &timestamppb.Timestamp{
809 Seconds: 0,
810 Nanos: 0,
811 },
812 },
813 want: "Jan 1 00:00:00.000",
814 },
815 {
816 name: "valid non-zero",
817 args: args{
818 layout: time.StampMilli,
819 t: &timestamppb.Timestamp{
820 Seconds: 1530984600,
821 Nanos: 123000000,
822 },
823 },
824 want: "Jul 7 17:30:00.123",
825 },
826 {
827 name: "invalid",
828 args: args{
829 layout: time.StampMilli,
830 t: &timestamppb.Timestamp{
831 Seconds: -1,
832 Nanos: -1,
833 },
834 },
835 want: "N/A",
836 },
837 {
838 name: "nil timestamp",
839 args: args{},
840 want: "N/A",
841 },
842 }
843 for _, tt := range tests {
844 t.Run(tt.name, func(t *testing.T) {
845 if got := fmtTimestamp(tt.args.layout, tt.args.t); got != tt.want {
846 t.Errorf("getTimestamp() = %v, want %v", got, tt.want)
847 }
848 })
849 }
850}
851

Callers

nothing calls this directly

Calls 3

fmtTimestampFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…