-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
110 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
FROM golang:1.19-alpine as builder | ||
FROM alpine:3.12.1 as builder | ||
|
||
ENV GO111MODULE=on | ||
ENV GOFLAGS=" -ldflags '-w'" | ||
ENV GOPROXY=direct | ||
ENV GOSUMDB=off | ||
|
||
COPY . . | ||
COPY --from=golang:1.19-alpine /usr/local/go/ /usr/local/go/ | ||
ENV PATH="/usr/local/go/bin:${PATH}" | ||
RUN apk --no-cache add make git gcc libtool musl-dev | ||
|
||
COPY go.mod . | ||
COPY go.sum . | ||
RUN go mod download | ||
RUN GOOS=linux GOARCH=amd64 go build | ||
COPY . / | ||
RUN make build; rm -rf $GOPATH/pkg/mod | ||
|
||
|
||
FROM alpine:3.14 as run | ||
FROM alpine:3.12.1 | ||
RUN apk add --no-progress --no-cache ca-certificates | ||
COPY --from=builder dipper-engine /dipper-engine | ||
COPY --from=builder /dipper-engine /dipper-engine | ||
ADD config.json /config.json | ||
ENTRYPOINT [ "/dipper-engine" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package conditional | ||
|
||
import ( | ||
"context" | ||
"github.com/dipper-iot/dipper-engine/data" | ||
"github.com/dipper-iot/dipper-engine/queue" | ||
"testing" | ||
) | ||
|
||
func TestConditionalRule_Run(t *testing.T) { | ||
a := ConditionalRule{} | ||
a.Initialize(context.TODO(), map[string]interface{}{}) | ||
qsub := queue.NewDefaultQueue[*data.InputEngine]("qsub") | ||
qpub := queue.NewDefaultQueue[*data.OutputEngine]("qpub") | ||
|
||
qsub.Publish(context.TODO(), &data.InputEngine{ | ||
SessionId: 1, | ||
ChanId: "1", | ||
IdNode: "noed1", | ||
FromEngine: "test", | ||
ToEngine: "test", | ||
Node: &data.NodeRule{ | ||
Option: map[string]interface{}{ | ||
"operator": map[string]interface{}{ | ||
"right": map[string]interface{}{ | ||
"value": "default.a", | ||
"type": "val", | ||
}, | ||
"left": map[string]interface{}{ | ||
"type": "val", | ||
"value": "default.b", | ||
}, | ||
"operator": "<>", | ||
"type": "operator", | ||
}, | ||
"set_param_result_to": "default.cond_a_b", | ||
"next_error": "4", | ||
"next_true": "4", | ||
"next_false": "4", | ||
}, | ||
End: false, | ||
Infinite: false, | ||
Debug: false, | ||
RuleId: "1", | ||
NodeId: "1", | ||
}, | ||
Data: map[string]interface{}{ | ||
"default": map[string]interface{}{ | ||
"a": 2, | ||
"b": 2, | ||
"x": 3, | ||
}, | ||
}, | ||
BranchMain: "default", | ||
}) | ||
qsub.Publish(context.TODO(), &data.InputEngine{ | ||
SessionId: 1, | ||
ChanId: "1", | ||
IdNode: "noed1", | ||
FromEngine: "test", | ||
ToEngine: "test", | ||
Node: &data.NodeRule{ | ||
Option: map[string]interface{}{ | ||
"operator": map[string]interface{}{ | ||
"right": map[string]interface{}{ | ||
"value": "default.f", | ||
"type": "val", | ||
}, | ||
"left": map[string]interface{}{ | ||
"type": "val", | ||
"value": "default.b", | ||
}, | ||
"operator": "<>", | ||
"type": "operator", | ||
}, | ||
"set_param_result_to": "default.cond_a_b", | ||
"next_error": "4", | ||
"next_true": "4", | ||
"next_false": "4", | ||
}, | ||
End: false, | ||
Infinite: false, | ||
Debug: false, | ||
RuleId: "1", | ||
NodeId: "1", | ||
}, | ||
Data: map[string]interface{}{ | ||
"default": map[string]interface{}{ | ||
"a": 2, | ||
"b": 2, | ||
"x": 3, | ||
}, | ||
}, | ||
BranchMain: "default", | ||
}) | ||
a.Run(context.TODO(), qsub.Subscribe, qpub.Publish) | ||
} |