(t *testing.T)
| 859 | } |
| 860 | |
| 861 | func TestRunCommand(t *testing.T) { |
| 862 | testutil.InstallZapLogger(t) |
| 863 | sut := createSystemUnderTest(t, createConfigManager(&v1.Config{ |
| 864 | Version: 4, |
| 865 | Modno: 1234, |
| 866 | Instance: "test", |
| 867 | Repos: []*v1.Repo{ |
| 868 | { |
| 869 | Id: "local", |
| 870 | Guid: cryptoutil.MustRandomID(cryptoutil.DefaultIDBits), |
| 871 | Uri: t.TempDir(), |
| 872 | Password: "test", |
| 873 | Flags: []string{"--no-cache"}, |
| 874 | }, |
| 875 | }, |
| 876 | })) |
| 877 | |
| 878 | ctx, cancel := testutil.WithDeadlineFromTest(t, context.Background()) |
| 879 | defer cancel() |
| 880 | go func() { |
| 881 | sut.orch.Run(ctx) |
| 882 | }() |
| 883 | |
| 884 | res, err := sut.handler.RunCommand(ctx, connect.NewRequest(&v1.RunCommandRequest{ |
| 885 | RepoId: "local", |
| 886 | Command: "help", |
| 887 | })) |
| 888 | if err != nil { |
| 889 | t.Fatalf("RunCommand() error = %v", err) |
| 890 | } |
| 891 | op, err := sut.oplog.Get(res.Msg.Value) |
| 892 | if err != nil { |
| 893 | t.Fatalf("Failed to find runcommand operation: %v", err) |
| 894 | } |
| 895 | |
| 896 | if op.Status != v1.OperationStatus_STATUS_SUCCESS { |
| 897 | t.Fatalf("Expected runcommand operation to succeed") |
| 898 | } |
| 899 | |
| 900 | cmdOp := op.GetOperationRunCommand() |
| 901 | if cmdOp == nil { |
| 902 | t.Fatalf("Expected runcommand operation to be of type OperationRunCommand") |
| 903 | } |
| 904 | if cmdOp.Command != "help" { |
| 905 | t.Fatalf("Expected runcommand operation to have correct command") |
| 906 | } |
| 907 | if cmdOp.OutputLogref == "" { |
| 908 | t.Fatalf("Expected runcommand operation to have output logref") |
| 909 | } |
| 910 | |
| 911 | log, err := sut.logStore.Open(cmdOp.OutputLogref) |
| 912 | if err != nil { |
| 913 | t.Fatalf("Failed to open log: %v", err) |
| 914 | } |
| 915 | defer log.Close() |
| 916 | |
| 917 | data, err := io.ReadAll(log) |
| 918 | if err != nil { |
nothing calls this directly
no test coverage detected