MCPcopy Index your code
hub / github.com/coder/coder / TestTemplateTTL

Function TestTemplateTTL

enterprise/coderd/schedule/template_test.go:900–1142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

898}
899
900func TestTemplateTTL(t *testing.T) {
901 t.Parallel()
902
903 tests := []struct {
904 name string
905 allowUserAutostop bool
906 fromTTL time.Duration
907 toTTL time.Duration
908 expected sql.NullInt64
909 }{
910 {
911 name: "AllowUserAutostopFalse/ModifyTTLDurationDown",
912 allowUserAutostop: false,
913 fromTTL: 24 * time.Hour,
914 toTTL: 1 * time.Hour,
915 expected: sql.NullInt64{Valid: true, Int64: int64(1 * time.Hour)},
916 },
917 {
918 name: "AllowUserAutostopFalse/ModifyTTLDurationUp",
919 allowUserAutostop: false,
920 fromTTL: 24 * time.Hour,
921 toTTL: 36 * time.Hour,
922 expected: sql.NullInt64{Valid: true, Int64: int64(36 * time.Hour)},
923 },
924 {
925 name: "AllowUserAutostopFalse/ModifyTTLDurationSame",
926 allowUserAutostop: false,
927 fromTTL: 24 * time.Hour,
928 toTTL: 24 * time.Hour,
929 expected: sql.NullInt64{Valid: true, Int64: int64(24 * time.Hour)},
930 },
931 {
932 name: "AllowUserAutostopFalse/DisableTTL",
933 allowUserAutostop: false,
934 fromTTL: 24 * time.Hour,
935 toTTL: 0,
936 expected: sql.NullInt64{},
937 },
938 {
939 name: "AllowUserAutostopTrue/ModifyTTLDurationDown",
940 allowUserAutostop: true,
941 fromTTL: 24 * time.Hour,
942 toTTL: 1 * time.Hour,
943 expected: sql.NullInt64{Valid: true, Int64: int64(24 * time.Hour)},
944 },
945 {
946 name: "AllowUserAutostopTrue/ModifyTTLDurationUp",
947 allowUserAutostop: true,
948 fromTTL: 24 * time.Hour,
949 toTTL: 36 * time.Hour,
950 expected: sql.NullInt64{Valid: true, Int64: int64(24 * time.Hour)},
951 },
952 {
953 name: "AllowUserAutostopTrue/ModifyTTLDurationSame",
954 allowUserAutostop: true,
955 fromTTL: 24 * time.Hour,
956 toTTL: 24 * time.Hour,
957 expected: sql.NullInt64{Valid: true, Int64: int64(24 * time.Hour)},

Callers

nothing calls this directly

Calls 15

SetMethod · 0.95
NewDBFunction · 0.92
ContextFunction · 0.92
UserFunction · 0.92
FileFunction · 0.92
ProvisionerJobFunction · 0.92
TemplateVersionFunction · 0.92
TemplateFunction · 0.92
NewNoopEnqueuerFunction · 0.92
WorkspaceFunction · 0.92

Tested by

no test coverage detected