MCPcopy
hub / github.com/google/mangle / TestIntegration_DurationBoundScenarios

Function TestIntegration_DurationBoundScenarios

engine/temporal_integration_test.go:645–823  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

643}
644
645func TestIntegration_DurationBoundScenarios(t *testing.T) {
646 // Setup: Reference time is 2024-01-20T12:00:00Z
647 refTime := time.Date(2024, 1, 20, 12, 0, 0, 0, time.UTC)
648
649 tests := []struct {
650 name string
651 decls []string
652 facts []string
653 rules []string
654 query string
655 want []string
656 }{
657 {
658 name: "diamond minus - within last 7 days",
659 decls: []string{"Decl event(Action) temporal."},
660 facts: []string{
661 "event(/login) @[2024-01-15T10:00:00Z].",
662 "event(/logout) @[2024-01-10T10:00:00Z].",
663 },
664 rules: []string{
665 "recent(Action) :- <-[0s, 7d] event(Action).",
666 },
667 query: "recent(X)",
668 want: []string{"recent(/login)"},
669 },
670 {
671 name: "box minus - active for all of last 24 hours",
672 decls: []string{"Decl active(S) temporal."},
673 facts: []string{
674 "active(/srv1) @[2024-01-19T00:00:00Z, 2024-01-21T00:00:00Z].",
675 "active(/srv2) @[2024-01-20T00:00:00Z, 2024-01-20T06:00:00Z].",
676 },
677 rules: []string{
678 "stable(S) :- [-[0s, 24h] active(S).",
679 },
680 query: "stable(X)",
681 want: []string{"stable(/srv1)"},
682 },
683 {
684 name: "diamond plus - upcoming maintenance in next 2 days",
685 decls: []string{"Decl maint(N) temporal."},
686 facts: []string{
687 "maint(/node1) @[2024-01-21T10:00:00Z].",
688 "maint(/node2) @[2024-01-25T10:00:00Z].",
689 },
690 rules: []string{
691 "warn(N) :- <+[0s, 2d] maint(N).",
692 },
693 query: "warn(X)",
694 want: []string{"warn(/node1)"},
695 },
696 {
697 name: "box plus - reserved for next 1 hour",
698 decls: []string{"Decl reserved(C) temporal."},
699 facts: []string{
700 "reserved(/cpu1) @[2024-01-20T12:00:00Z, 2024-01-20T14:00:00Z].",
701 "reserved(/cpu2) @[2024-01-20T12:00:00Z, 2024-01-20T12:30:00Z].",
702 },

Callers

nothing calls this directly

Calls 12

AddEternalMethod · 0.95
AddMethod · 0.95
GetAllFactsMethod · 0.95
NewTemporalStoreFunction · 0.92
UnitFunction · 0.92
AnalyzeOneUnitFunction · 0.92
AtomFunction · 0.92
EvalProgramFunction · 0.85
WithTemporalStoreFunction · 0.85
WithEvaluationTimeFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected