From fd38a8bfa2954c7818d79e94b7658c5ad7f2c4b5 Mon Sep 17 00:00:00 2001 From: "Chang, Hui-Tang" Date: Thu, 13 Jun 2024 17:32:42 +0800 Subject: [PATCH] fix: fix component document links (#159) Because - The component document links are wrong since website changed the routes. This commit - Fixes component document links. --- .github/CONTRIBUTING.md | 2 +- ai/archetypeai/v0/config/definition.json | 2 +- ai/huggingface/v0/config/definition.json | 2 +- ai/instill/v0/config/definition.json | 2 +- ai/openai/v0/config/definition.json | 2 +- ai/stabilityai/v0/config/definition.json | 2 +- .../googlesearch/v0/config/definition.json | 2 +- application/numbers/v0/config/definition.json | 2 +- application/restapi/v0/config/definition.json | 2 +- application/slack/v0/config/definition.json | 2 +- application/website/v0/config/definition.json | 2 +- base/testdata/connectorDef.json | 2 +- base/testdata/operatorDef.json | 2 +- base/testdata/wantConnectorDefinition.json | 2 +- base/testdata/wantOperatorDefinition.json | 2 +- data/bigquery/v0/config/definition.json | 2 +- .../v0/config/definition.json | 2 +- data/pinecone/v0/config/definition.json | 2 +- {application => data}/redis/v0/README.mdx | 4 +- .../redis/v0/assets/redis.svg | 0 .../redis/v0/chat_history.go | 0 {application => data}/redis/v0/client.go | 0 .../redis/v0/config/definition.json | 6 +- .../redis/v0/config/setup.json | 0 .../redis/v0/config/tasks.json | 0 {application => data}/redis/v0/main.go | 0 internal/mock/command_runner_mock.gen.go | 86 ++++++++--- internal/mock/write_closer_mock.gen.go | 137 ++++++++++++++---- operator/base64/v0/config/definition.json | 2 +- operator/document/v0/README.mdx | 2 +- operator/document/v0/config/definition.json | 2 +- operator/image/v0/config/definition.json | 2 +- operator/json/v0/config/definition.json | 2 +- operator/text/v0/config/definition.json | 2 +- store/store.go | 2 +- 35 files changed, 202 insertions(+), 81 deletions(-) rename {application => data}/redis/v0/README.mdx (94%) rename {application => data}/redis/v0/assets/redis.svg (100%) rename {application => data}/redis/v0/chat_history.go (100%) rename {application => data}/redis/v0/client.go (100%) rename {application => data}/redis/v0/config/definition.json (77%) rename {application => data}/redis/v0/config/setup.json (100%) rename {application => data}/redis/v0/config/tasks.json (100%) rename {application => data}/redis/v0/main.go (100%) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a220a336..d24209b3 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -279,7 +279,7 @@ component. "TASK_GREET" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/operators/hello", + "documentation_url": "https://www.instill.tech/docs/component/operator/hello", "icon": "assets/hello.svg", "id": "hello", "public": true, diff --git a/ai/archetypeai/v0/config/definition.json b/ai/archetypeai/v0/config/definition.json index 44328226..8cfb3109 100644 --- a/ai/archetypeai/v0/config/definition.json +++ b/ai/archetypeai/v0/config/definition.json @@ -5,7 +5,7 @@ "TASK_UPLOAD_FILE" ], "custom": false, - "documentation_url": "", + "documentation_url": "https://www.instill.tech/docs/component/ai/archetypeai", "icon": "assets/archetype-ai.svg", "icon_url": "", "id": "archetype-ai", diff --git a/ai/huggingface/v0/config/definition.json b/ai/huggingface/v0/config/definition.json index 7b56a273..51a47b4a 100644 --- a/ai/huggingface/v0/config/definition.json +++ b/ai/huggingface/v0/config/definition.json @@ -19,7 +19,7 @@ "TASK_AUDIO_CLASSIFICATION" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/ai-connectors/hugging-face", + "documentation_url": "https://www.instill.tech/docs/component/ai/huggingface", "icon": "assets/hugging-face.svg", "icon_url": "", "id": "hugging-face", diff --git a/ai/instill/v0/config/definition.json b/ai/instill/v0/config/definition.json index 11824bae..13c5d30e 100644 --- a/ai/instill/v0/config/definition.json +++ b/ai/instill/v0/config/definition.json @@ -13,7 +13,7 @@ "TASK_IMAGE_TO_IMAGE" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/ai-connectors/instill", + "documentation_url": "https://www.instill.tech/docs/component/ai/instill", "icon": "assets/instill-model.svg", "icon_url": "", "id": "instill-model", diff --git a/ai/openai/v0/config/definition.json b/ai/openai/v0/config/definition.json index 6007b124..dbc6030a 100644 --- a/ai/openai/v0/config/definition.json +++ b/ai/openai/v0/config/definition.json @@ -7,7 +7,7 @@ "TASK_TEXT_TO_IMAGE" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/ai-connectors/openai", + "documentation_url": "https://www.instill.tech/docs/component/ai/openai", "icon": "assets/openai.svg", "icon_url": "", "id": "openai", diff --git a/ai/stabilityai/v0/config/definition.json b/ai/stabilityai/v0/config/definition.json index defe06b5..481d6537 100644 --- a/ai/stabilityai/v0/config/definition.json +++ b/ai/stabilityai/v0/config/definition.json @@ -4,7 +4,7 @@ "TASK_IMAGE_TO_IMAGE" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/ai-connectors/stabilityai", + "documentation_url": "https://www.instill.tech/docs/component/ai/stabilityai", "icon": "assets/stability-ai.svg", "icon_url": "", "id": "stability-ai", diff --git a/application/googlesearch/v0/config/definition.json b/application/googlesearch/v0/config/definition.json index cb63bf79..cb70c90f 100644 --- a/application/googlesearch/v0/config/definition.json +++ b/application/googlesearch/v0/config/definition.json @@ -3,7 +3,7 @@ "TASK_SEARCH" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/data-connectors/googlesearch", + "documentation_url": "https://www.instill.tech/docs/component/application/googlesearch", "icon": "assets/google-search.svg", "icon_url": "", "id": "google-search", diff --git a/application/numbers/v0/config/definition.json b/application/numbers/v0/config/definition.json index 67e4c99d..b48a94e0 100644 --- a/application/numbers/v0/config/definition.json +++ b/application/numbers/v0/config/definition.json @@ -3,7 +3,7 @@ "TASK_REGISTER" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/app-connectors/numbers", + "documentation_url": "https://www.instill.tech/docs/component/application/numbers", "icon": "assets/numbers.svg", "icon_url": "", "id": "numbers", diff --git a/application/restapi/v0/config/definition.json b/application/restapi/v0/config/definition.json index c52c6e59..b9f3dac9 100644 --- a/application/restapi/v0/config/definition.json +++ b/application/restapi/v0/config/definition.json @@ -9,7 +9,7 @@ "TASK_OPTIONS" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/data-connectors/restapi", + "documentation_url": "https://www.instill.tech/docs/component/application/restapi", "icon": "assets/restapi.svg", "icon_url": "", "id": "restapi", diff --git a/application/slack/v0/config/definition.json b/application/slack/v0/config/definition.json index 366de321..8b342bf8 100644 --- a/application/slack/v0/config/definition.json +++ b/application/slack/v0/config/definition.json @@ -4,7 +4,7 @@ "TASK_WRITE_MESSAGE" ], "custom": false, - "documentation_url": "", + "documentation_url": "https://www.instill.tech/docs/component/application/slack", "icon": "assets/slack.svg", "icon_url": "", "id": "slack", diff --git a/application/website/v0/config/definition.json b/application/website/v0/config/definition.json index eaea7455..cbda3e08 100644 --- a/application/website/v0/config/definition.json +++ b/application/website/v0/config/definition.json @@ -3,7 +3,7 @@ "TASK_SCRAPE_WEBSITE" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/data-connectors/website", + "documentation_url": "https://www.instill.tech/docs/component/application/website", "icon": "assets/website.svg", "icon_url": "", "id": "website", diff --git a/base/testdata/connectorDef.json b/base/testdata/connectorDef.json index 25c7a909..66753695 100644 --- a/base/testdata/connectorDef.json +++ b/base/testdata/connectorDef.json @@ -5,7 +5,7 @@ "TASK_TEXT_EMBEDDINGS" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/ai-connectors/openai", + "documentation_url": "https://www.instill.tech/docs/component/ai/openai", "icon": "OpenAI/openai.svg", "id": "openai", "public": true, diff --git a/base/testdata/operatorDef.json b/base/testdata/operatorDef.json index c0afa3cc..40b242a4 100644 --- a/base/testdata/operatorDef.json +++ b/base/testdata/operatorDef.json @@ -5,7 +5,7 @@ "TASK_MARSHAL" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/operators/json", + "documentation_url": "https://www.instill.tech/docs/component/operator/json", "icon": "Instill AI/json.svg", "icon_url": "", "id": "json", diff --git a/base/testdata/wantConnectorDefinition.json b/base/testdata/wantConnectorDefinition.json index 33db9dd6..ddfc48de 100644 --- a/base/testdata/wantConnectorDefinition.json +++ b/base/testdata/wantConnectorDefinition.json @@ -3,7 +3,7 @@ "uid": "9fb6a2cb-bff5-4c69-bc6d-4538dd8e3362", "id": "openai", "title": "OpenAI", - "documentation_url": "https://www.instill.tech/docs/latest/vdp/ai-connectors/openai", + "documentation_url": "https://www.instill.tech/docs/component/ai/openai", "icon": "OpenAI/openai.svg", "spec": { "component_specification": { diff --git a/base/testdata/wantOperatorDefinition.json b/base/testdata/wantOperatorDefinition.json index 77832d04..e7529271 100644 --- a/base/testdata/wantOperatorDefinition.json +++ b/base/testdata/wantOperatorDefinition.json @@ -3,7 +3,7 @@ "uid": "28f53d15-6150-46e6-99aa-f76b70a926c0", "id": "json", "title": "JSON", - "documentation_url": "https://www.instill.tech/docs/latest/vdp/operators/json", + "documentation_url": "https://www.instill.tech/docs/component/operator/json", "icon": "Instill AI/json.svg", "spec": { "component_specification": { diff --git a/data/bigquery/v0/config/definition.json b/data/bigquery/v0/config/definition.json index 415b2797..2eb3070b 100644 --- a/data/bigquery/v0/config/definition.json +++ b/data/bigquery/v0/config/definition.json @@ -3,7 +3,7 @@ "TASK_INSERT" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/data-connectors/bigquery", + "documentation_url": "https://www.instill.tech/docs/component/data/bigquery", "icon": "assets/bigquery.svg", "icon_url": "", "id": "bigquery", diff --git a/data/googlecloudstorage/v0/config/definition.json b/data/googlecloudstorage/v0/config/definition.json index 11977460..49f17677 100644 --- a/data/googlecloudstorage/v0/config/definition.json +++ b/data/googlecloudstorage/v0/config/definition.json @@ -3,7 +3,7 @@ "TASK_UPLOAD" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/data-connectors/googlecloudstorage", + "documentation_url": "https://www.instill.tech/docs/component/data/googlecloudstorage", "icon": "assets/gcs.svg", "icon_url": "", "id": "gcs", diff --git a/data/pinecone/v0/config/definition.json b/data/pinecone/v0/config/definition.json index 5ac72ebe..d6c282b4 100644 --- a/data/pinecone/v0/config/definition.json +++ b/data/pinecone/v0/config/definition.json @@ -4,7 +4,7 @@ "TASK_UPSERT" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/data-connectors/pinecone", + "documentation_url": "https://www.instill.tech/docs/component/data/pinecone", "icon": "assets/pinecone.svg", "icon_url": "https://www.pinecone.io/favicon.ico", "id": "pinecone", diff --git a/application/redis/v0/README.mdx b/data/redis/v0/README.mdx similarity index 94% rename from application/redis/v0/README.mdx rename to data/redis/v0/README.mdx index 989876a5..5f0fe4a1 100644 --- a/application/redis/v0/README.mdx +++ b/data/redis/v0/README.mdx @@ -5,7 +5,7 @@ draft: false description: "Learn about how to set up a VDP Redis component https://github.com/instill-ai/instill-core" --- -The Redis component is a application component that allows users to manage data in NoSQL Redis databases. +The Redis component is a data component that allows users to manage data in NoSQL Redis databases. It can carry out the following tasks: - [Retrieve Chat History](#retrieve-chat-history) @@ -18,7 +18,7 @@ It can carry out the following tasks: ## Configuration -The component configuration is defined and maintained [here](https://github.com/instill-ai/component/blob/main/application/redis/v0/config/definition.json). +The component configuration is defined and maintained [here](https://github.com/instill-ai/component/blob/main/data/redis/v0/config/definition.json). ## Setup diff --git a/application/redis/v0/assets/redis.svg b/data/redis/v0/assets/redis.svg similarity index 100% rename from application/redis/v0/assets/redis.svg rename to data/redis/v0/assets/redis.svg diff --git a/application/redis/v0/chat_history.go b/data/redis/v0/chat_history.go similarity index 100% rename from application/redis/v0/chat_history.go rename to data/redis/v0/chat_history.go diff --git a/application/redis/v0/client.go b/data/redis/v0/client.go similarity index 100% rename from application/redis/v0/client.go rename to data/redis/v0/client.go diff --git a/application/redis/v0/config/definition.json b/data/redis/v0/config/definition.json similarity index 77% rename from application/redis/v0/config/definition.json rename to data/redis/v0/config/definition.json index a6517bf9..875cbea2 100644 --- a/application/redis/v0/config/definition.json +++ b/data/redis/v0/config/definition.json @@ -5,18 +5,18 @@ "TASK_WRITE_MULTI_MODAL_CHAT_MESSAGE" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/data-connectors/redis", + "documentation_url": "https://www.instill.tech/docs/component/data/redis", "icon": "assets/redis.svg", "icon_url": "", "id": "redis", "public": true, "title": "Redis", "description": "Manage data in NoSQL Redis databases", - "type": "COMPONENT_TYPE_APPLICATION", + "type": "COMPONENT_TYPE_DATA", "uid": "fd0ad325-f2f7-41f3-b247-6c71d571b1b8", "vendor": "Redis Labs", "vendor_attributes": {}, "version": "0.1.1", - "source_url": "https://github.com/instill-ai/component/blob/main/application/redis/v0", + "source_url": "https://github.com/instill-ai/component/blob/main/data/redis/v0", "release_stage": "RELEASE_STAGE_ALPHA" } diff --git a/application/redis/v0/config/setup.json b/data/redis/v0/config/setup.json similarity index 100% rename from application/redis/v0/config/setup.json rename to data/redis/v0/config/setup.json diff --git a/application/redis/v0/config/tasks.json b/data/redis/v0/config/tasks.json similarity index 100% rename from application/redis/v0/config/tasks.json rename to data/redis/v0/config/tasks.json diff --git a/application/redis/v0/main.go b/data/redis/v0/main.go similarity index 100% rename from application/redis/v0/main.go rename to data/redis/v0/main.go diff --git a/internal/mock/command_runner_mock.gen.go b/internal/mock/command_runner_mock.gen.go index 4603aaff..f230e8e5 100644 --- a/internal/mock/command_runner_mock.gen.go +++ b/internal/mock/command_runner_mock.gen.go @@ -1,4 +1,4 @@ -// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. +// Code generated by http://github.com/gojuno/minimock (v3.3.9). DO NOT EDIT. package mock @@ -50,6 +50,8 @@ type mCommandRunnerMockCombinedOutput struct { mock *CommandRunnerMock defaultExpectation *CommandRunnerMockCombinedOutputExpectation expectations []*CommandRunnerMockCombinedOutputExpectation + + expectedInvocations uint64 } // CommandRunnerMockCombinedOutputExpectation specifies expectation struct of the commandRunner.CombinedOutput @@ -117,6 +119,26 @@ func (mmCombinedOutput *mCommandRunnerMockCombinedOutput) Set(f func() (ba1 []by return mmCombinedOutput.mock } +// Times sets number of times commandRunner.CombinedOutput should be invoked +func (mmCombinedOutput *mCommandRunnerMockCombinedOutput) Times(n uint64) *mCommandRunnerMockCombinedOutput { + if n == 0 { + mmCombinedOutput.mock.t.Fatalf("Times of CommandRunnerMock.CombinedOutput mock can not be zero") + } + mm_atomic.StoreUint64(&mmCombinedOutput.expectedInvocations, n) + return mmCombinedOutput +} + +func (mmCombinedOutput *mCommandRunnerMockCombinedOutput) invocationsDone() bool { + if len(mmCombinedOutput.expectations) == 0 && mmCombinedOutput.defaultExpectation == nil && mmCombinedOutput.mock.funcCombinedOutput == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmCombinedOutput.mock.afterCombinedOutputCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmCombinedOutput.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + // CombinedOutput implements document.commandRunner func (mmCombinedOutput *CommandRunnerMock) CombinedOutput() (ba1 []byte, err error) { mm_atomic.AddUint64(&mmCombinedOutput.beforeCombinedOutputCounter, 1) @@ -161,15 +183,7 @@ func (m *CommandRunnerMock) MinimockCombinedOutputDone() bool { } } - // if default expectation was set then invocations count should be greater than zero - if m.CombinedOutputMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterCombinedOutputCounter) < 1 { - return false - } - // if func was set then invocations count should be greater than zero - if m.funcCombinedOutput != nil && mm_atomic.LoadUint64(&m.afterCombinedOutputCounter) < 1 { - return false - } - return true + return m.CombinedOutputMock.invocationsDone() } // MinimockCombinedOutputInspect logs each unmet expectation @@ -180,20 +194,28 @@ func (m *CommandRunnerMock) MinimockCombinedOutputInspect() { } } + afterCombinedOutputCounter := mm_atomic.LoadUint64(&m.afterCombinedOutputCounter) // if default expectation was set then invocations count should be greater than zero - if m.CombinedOutputMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterCombinedOutputCounter) < 1 { + if m.CombinedOutputMock.defaultExpectation != nil && afterCombinedOutputCounter < 1 { m.t.Error("Expected call to CommandRunnerMock.CombinedOutput") } // if func was set then invocations count should be greater than zero - if m.funcCombinedOutput != nil && mm_atomic.LoadUint64(&m.afterCombinedOutputCounter) < 1 { + if m.funcCombinedOutput != nil && afterCombinedOutputCounter < 1 { m.t.Error("Expected call to CommandRunnerMock.CombinedOutput") } + + if !m.CombinedOutputMock.invocationsDone() && afterCombinedOutputCounter > 0 { + m.t.Errorf("Expected %d calls to CommandRunnerMock.CombinedOutput but found %d calls", + mm_atomic.LoadUint64(&m.CombinedOutputMock.expectedInvocations), afterCombinedOutputCounter) + } } type mCommandRunnerMockStdinPipe struct { mock *CommandRunnerMock defaultExpectation *CommandRunnerMockStdinPipeExpectation expectations []*CommandRunnerMockStdinPipeExpectation + + expectedInvocations uint64 } // CommandRunnerMockStdinPipeExpectation specifies expectation struct of the commandRunner.StdinPipe @@ -261,6 +283,26 @@ func (mmStdinPipe *mCommandRunnerMockStdinPipe) Set(f func() (w1 io.WriteCloser, return mmStdinPipe.mock } +// Times sets number of times commandRunner.StdinPipe should be invoked +func (mmStdinPipe *mCommandRunnerMockStdinPipe) Times(n uint64) *mCommandRunnerMockStdinPipe { + if n == 0 { + mmStdinPipe.mock.t.Fatalf("Times of CommandRunnerMock.StdinPipe mock can not be zero") + } + mm_atomic.StoreUint64(&mmStdinPipe.expectedInvocations, n) + return mmStdinPipe +} + +func (mmStdinPipe *mCommandRunnerMockStdinPipe) invocationsDone() bool { + if len(mmStdinPipe.expectations) == 0 && mmStdinPipe.defaultExpectation == nil && mmStdinPipe.mock.funcStdinPipe == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmStdinPipe.mock.afterStdinPipeCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmStdinPipe.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + // StdinPipe implements document.commandRunner func (mmStdinPipe *CommandRunnerMock) StdinPipe() (w1 io.WriteCloser, err error) { mm_atomic.AddUint64(&mmStdinPipe.beforeStdinPipeCounter, 1) @@ -305,15 +347,7 @@ func (m *CommandRunnerMock) MinimockStdinPipeDone() bool { } } - // if default expectation was set then invocations count should be greater than zero - if m.StdinPipeMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterStdinPipeCounter) < 1 { - return false - } - // if func was set then invocations count should be greater than zero - if m.funcStdinPipe != nil && mm_atomic.LoadUint64(&m.afterStdinPipeCounter) < 1 { - return false - } - return true + return m.StdinPipeMock.invocationsDone() } // MinimockStdinPipeInspect logs each unmet expectation @@ -324,14 +358,20 @@ func (m *CommandRunnerMock) MinimockStdinPipeInspect() { } } + afterStdinPipeCounter := mm_atomic.LoadUint64(&m.afterStdinPipeCounter) // if default expectation was set then invocations count should be greater than zero - if m.StdinPipeMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterStdinPipeCounter) < 1 { + if m.StdinPipeMock.defaultExpectation != nil && afterStdinPipeCounter < 1 { m.t.Error("Expected call to CommandRunnerMock.StdinPipe") } // if func was set then invocations count should be greater than zero - if m.funcStdinPipe != nil && mm_atomic.LoadUint64(&m.afterStdinPipeCounter) < 1 { + if m.funcStdinPipe != nil && afterStdinPipeCounter < 1 { m.t.Error("Expected call to CommandRunnerMock.StdinPipe") } + + if !m.StdinPipeMock.invocationsDone() && afterStdinPipeCounter > 0 { + m.t.Errorf("Expected %d calls to CommandRunnerMock.StdinPipe but found %d calls", + mm_atomic.LoadUint64(&m.StdinPipeMock.expectedInvocations), afterStdinPipeCounter) + } } // MinimockFinish checks that all mocked methods have been called the expected number of times diff --git a/internal/mock/write_closer_mock.gen.go b/internal/mock/write_closer_mock.gen.go index 349f245d..d49552a4 100644 --- a/internal/mock/write_closer_mock.gen.go +++ b/internal/mock/write_closer_mock.gen.go @@ -1,4 +1,4 @@ -// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. +// Code generated by http://github.com/gojuno/minimock (v3.3.9). DO NOT EDIT. package mock @@ -50,6 +50,8 @@ type mWriteCloserMockClose struct { mock *WriteCloserMock defaultExpectation *WriteCloserMockCloseExpectation expectations []*WriteCloserMockCloseExpectation + + expectedInvocations uint64 } // WriteCloserMockCloseExpectation specifies expectation struct of the WriteCloser.Close @@ -116,6 +118,26 @@ func (mmClose *mWriteCloserMockClose) Set(f func() (err error)) *WriteCloserMock return mmClose.mock } +// Times sets number of times WriteCloser.Close should be invoked +func (mmClose *mWriteCloserMockClose) Times(n uint64) *mWriteCloserMockClose { + if n == 0 { + mmClose.mock.t.Fatalf("Times of WriteCloserMock.Close mock can not be zero") + } + mm_atomic.StoreUint64(&mmClose.expectedInvocations, n) + return mmClose +} + +func (mmClose *mWriteCloserMockClose) invocationsDone() bool { + if len(mmClose.expectations) == 0 && mmClose.defaultExpectation == nil && mmClose.mock.funcClose == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmClose.mock.afterCloseCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmClose.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + // Close implements io.WriteCloser func (mmClose *WriteCloserMock) Close() (err error) { mm_atomic.AddUint64(&mmClose.beforeCloseCounter, 1) @@ -160,15 +182,7 @@ func (m *WriteCloserMock) MinimockCloseDone() bool { } } - // if default expectation was set then invocations count should be greater than zero - if m.CloseMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterCloseCounter) < 1 { - return false - } - // if func was set then invocations count should be greater than zero - if m.funcClose != nil && mm_atomic.LoadUint64(&m.afterCloseCounter) < 1 { - return false - } - return true + return m.CloseMock.invocationsDone() } // MinimockCloseInspect logs each unmet expectation @@ -179,14 +193,20 @@ func (m *WriteCloserMock) MinimockCloseInspect() { } } + afterCloseCounter := mm_atomic.LoadUint64(&m.afterCloseCounter) // if default expectation was set then invocations count should be greater than zero - if m.CloseMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterCloseCounter) < 1 { + if m.CloseMock.defaultExpectation != nil && afterCloseCounter < 1 { m.t.Error("Expected call to WriteCloserMock.Close") } // if func was set then invocations count should be greater than zero - if m.funcClose != nil && mm_atomic.LoadUint64(&m.afterCloseCounter) < 1 { + if m.funcClose != nil && afterCloseCounter < 1 { m.t.Error("Expected call to WriteCloserMock.Close") } + + if !m.CloseMock.invocationsDone() && afterCloseCounter > 0 { + m.t.Errorf("Expected %d calls to WriteCloserMock.Close but found %d calls", + mm_atomic.LoadUint64(&m.CloseMock.expectedInvocations), afterCloseCounter) + } } type mWriteCloserMockWrite struct { @@ -196,14 +216,17 @@ type mWriteCloserMockWrite struct { callArgs []*WriteCloserMockWriteParams mutex sync.RWMutex + + expectedInvocations uint64 } // WriteCloserMockWriteExpectation specifies expectation struct of the WriteCloser.Write type WriteCloserMockWriteExpectation struct { - mock *WriteCloserMock - params *WriteCloserMockWriteParams - results *WriteCloserMockWriteResults - Counter uint64 + mock *WriteCloserMock + params *WriteCloserMockWriteParams + paramPtrs *WriteCloserMockWriteParamPtrs + results *WriteCloserMockWriteResults + Counter uint64 } // WriteCloserMockWriteParams contains parameters of the WriteCloser.Write @@ -211,6 +234,11 @@ type WriteCloserMockWriteParams struct { p []byte } +// WriteCloserMockWriteParamPtrs contains pointers to parameters of the WriteCloser.Write +type WriteCloserMockWriteParamPtrs struct { + p *[]byte +} + // WriteCloserMockWriteResults contains results of the WriteCloser.Write type WriteCloserMockWriteResults struct { n int @@ -227,6 +255,10 @@ func (mmWrite *mWriteCloserMockWrite) Expect(p []byte) *mWriteCloserMockWrite { mmWrite.defaultExpectation = &WriteCloserMockWriteExpectation{} } + if mmWrite.defaultExpectation.paramPtrs != nil { + mmWrite.mock.t.Fatalf("WriteCloserMock.Write mock is already set by ExpectParams functions") + } + mmWrite.defaultExpectation.params = &WriteCloserMockWriteParams{p} for _, e := range mmWrite.expectations { if minimock.Equal(e.params, mmWrite.defaultExpectation.params) { @@ -237,6 +269,28 @@ func (mmWrite *mWriteCloserMockWrite) Expect(p []byte) *mWriteCloserMockWrite { return mmWrite } +// ExpectPParam1 sets up expected param p for WriteCloser.Write +func (mmWrite *mWriteCloserMockWrite) ExpectPParam1(p []byte) *mWriteCloserMockWrite { + if mmWrite.mock.funcWrite != nil { + mmWrite.mock.t.Fatalf("WriteCloserMock.Write mock is already set by Set") + } + + if mmWrite.defaultExpectation == nil { + mmWrite.defaultExpectation = &WriteCloserMockWriteExpectation{} + } + + if mmWrite.defaultExpectation.params != nil { + mmWrite.mock.t.Fatalf("WriteCloserMock.Write mock is already set by Expect") + } + + if mmWrite.defaultExpectation.paramPtrs == nil { + mmWrite.defaultExpectation.paramPtrs = &WriteCloserMockWriteParamPtrs{} + } + mmWrite.defaultExpectation.paramPtrs.p = &p + + return mmWrite +} + // Inspect accepts an inspector function that has same arguments as the WriteCloser.Write func (mmWrite *mWriteCloserMockWrite) Inspect(f func(p []byte)) *mWriteCloserMockWrite { if mmWrite.mock.inspectFuncWrite != nil { @@ -296,6 +350,26 @@ func (e *WriteCloserMockWriteExpectation) Then(n int, err error) *WriteCloserMoc return e.mock } +// Times sets number of times WriteCloser.Write should be invoked +func (mmWrite *mWriteCloserMockWrite) Times(n uint64) *mWriteCloserMockWrite { + if n == 0 { + mmWrite.mock.t.Fatalf("Times of WriteCloserMock.Write mock can not be zero") + } + mm_atomic.StoreUint64(&mmWrite.expectedInvocations, n) + return mmWrite +} + +func (mmWrite *mWriteCloserMockWrite) invocationsDone() bool { + if len(mmWrite.expectations) == 0 && mmWrite.defaultExpectation == nil && mmWrite.mock.funcWrite == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmWrite.mock.afterWriteCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmWrite.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + // Write implements io.WriteCloser func (mmWrite *WriteCloserMock) Write(p []byte) (n int, err error) { mm_atomic.AddUint64(&mmWrite.beforeWriteCounter, 1) @@ -322,8 +396,17 @@ func (mmWrite *WriteCloserMock) Write(p []byte) (n int, err error) { if mmWrite.WriteMock.defaultExpectation != nil { mm_atomic.AddUint64(&mmWrite.WriteMock.defaultExpectation.Counter, 1) mm_want := mmWrite.WriteMock.defaultExpectation.params + mm_want_ptrs := mmWrite.WriteMock.defaultExpectation.paramPtrs + mm_got := WriteCloserMockWriteParams{p} - if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + + if mm_want_ptrs != nil { + + if mm_want_ptrs.p != nil && !minimock.Equal(*mm_want_ptrs.p, mm_got.p) { + mmWrite.t.Errorf("WriteCloserMock.Write got unexpected parameter p, want: %#v, got: %#v%s\n", *mm_want_ptrs.p, mm_got.p, minimock.Diff(*mm_want_ptrs.p, mm_got.p)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { mmWrite.t.Errorf("WriteCloserMock.Write got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) } @@ -372,15 +455,7 @@ func (m *WriteCloserMock) MinimockWriteDone() bool { } } - // if default expectation was set then invocations count should be greater than zero - if m.WriteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterWriteCounter) < 1 { - return false - } - // if func was set then invocations count should be greater than zero - if m.funcWrite != nil && mm_atomic.LoadUint64(&m.afterWriteCounter) < 1 { - return false - } - return true + return m.WriteMock.invocationsDone() } // MinimockWriteInspect logs each unmet expectation @@ -391,8 +466,9 @@ func (m *WriteCloserMock) MinimockWriteInspect() { } } + afterWriteCounter := mm_atomic.LoadUint64(&m.afterWriteCounter) // if default expectation was set then invocations count should be greater than zero - if m.WriteMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterWriteCounter) < 1 { + if m.WriteMock.defaultExpectation != nil && afterWriteCounter < 1 { if m.WriteMock.defaultExpectation.params == nil { m.t.Error("Expected call to WriteCloserMock.Write") } else { @@ -400,9 +476,14 @@ func (m *WriteCloserMock) MinimockWriteInspect() { } } // if func was set then invocations count should be greater than zero - if m.funcWrite != nil && mm_atomic.LoadUint64(&m.afterWriteCounter) < 1 { + if m.funcWrite != nil && afterWriteCounter < 1 { m.t.Error("Expected call to WriteCloserMock.Write") } + + if !m.WriteMock.invocationsDone() && afterWriteCounter > 0 { + m.t.Errorf("Expected %d calls to WriteCloserMock.Write but found %d calls", + mm_atomic.LoadUint64(&m.WriteMock.expectedInvocations), afterWriteCounter) + } } // MinimockFinish checks that all mocked methods have been called the expected number of times diff --git a/operator/base64/v0/config/definition.json b/operator/base64/v0/config/definition.json index ebbe0d1e..b8099681 100644 --- a/operator/base64/v0/config/definition.json +++ b/operator/base64/v0/config/definition.json @@ -4,7 +4,7 @@ "TASK_DECODE" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/operators/base64", + "documentation_url": "https://www.instill.tech/docs/component/operator/base64", "icon": "assets/base64.svg", "icon_url": "", "id": "base64", diff --git a/operator/document/v0/README.mdx b/operator/document/v0/README.mdx index 3c7e895b..702db4dc 100644 --- a/operator/document/v0/README.mdx +++ b/operator/document/v0/README.mdx @@ -5,7 +5,7 @@ draft: false description: "Learn about how to set up a VDP Document component https://github.com/instill-ai/instill-core" --- -The Document component is a component that allows users to manipulate Document files. +The Document component is an operator component that allows users to manipulate Document files. It can carry out the following tasks: - [Convert To Markdown](#convert-to-markdown) diff --git a/operator/document/v0/config/definition.json b/operator/document/v0/config/definition.json index 60181c0c..2d1caedd 100644 --- a/operator/document/v0/config/definition.json +++ b/operator/document/v0/config/definition.json @@ -3,7 +3,7 @@ "TASK_CONVERT_TO_MARKDOWN" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/operators/document", + "documentation_url": "https://www.instill.tech/docs/component/operator/document", "icon": "assets/document.svg", "id": "document", "public": true, diff --git a/operator/image/v0/config/definition.json b/operator/image/v0/config/definition.json index b47e68ee..eb01ef28 100644 --- a/operator/image/v0/config/definition.json +++ b/operator/image/v0/config/definition.json @@ -8,7 +8,7 @@ "TASK_DRAW_SEMANTIC_SEGMENTATION" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/operators/image", + "documentation_url": "https://www.instill.tech/docs/component/operator/image", "icon": "assets/image.svg", "icon_url": "", "id": "image", diff --git a/operator/json/v0/config/definition.json b/operator/json/v0/config/definition.json index 0570278e..ba2f3f12 100644 --- a/operator/json/v0/config/definition.json +++ b/operator/json/v0/config/definition.json @@ -5,7 +5,7 @@ "TASK_JQ" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/operators/json", + "documentation_url": "https://www.instill.tech/docs/component/operator/json", "icon": "assets/json.svg", "icon_url": "", "id": "json", diff --git a/operator/text/v0/config/definition.json b/operator/text/v0/config/definition.json index a4237adc..e5d3f465 100644 --- a/operator/text/v0/config/definition.json +++ b/operator/text/v0/config/definition.json @@ -5,7 +5,7 @@ "TASK_CHUNK_TEXT" ], "custom": false, - "documentation_url": "https://www.instill.tech/docs/latest/vdp/operators/text", + "documentation_url": "https://www.instill.tech/docs/component/operator/text", "icon": "assets/text.svg", "icon_url": "", "id": "text", diff --git a/store/store.go b/store/store.go index c03b5863..0ef603cf 100644 --- a/store/store.go +++ b/store/store.go @@ -16,7 +16,6 @@ import ( "github.com/instill-ai/component/ai/stabilityai/v0" "github.com/instill-ai/component/application/googlesearch/v0" "github.com/instill-ai/component/application/numbers/v0" - "github.com/instill-ai/component/application/redis/v0" "github.com/instill-ai/component/application/restapi/v0" "github.com/instill-ai/component/application/slack/v0" "github.com/instill-ai/component/application/website/v0" @@ -24,6 +23,7 @@ import ( "github.com/instill-ai/component/data/bigquery/v0" "github.com/instill-ai/component/data/googlecloudstorage/v0" "github.com/instill-ai/component/data/pinecone/v0" + "github.com/instill-ai/component/data/redis/v0" "github.com/instill-ai/component/operator/base64/v0" "github.com/instill-ai/component/operator/document/v0" "github.com/instill-ai/component/operator/image/v0"