You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iggy.apache.org by "haze518 (via GitHub)" <gi...@apache.org> on 2025/07/23 01:15:24 UTC

Re: [PR] feat(go): add godog go bdd test according to scenarios. [iggy]

haze518 commented on code in PR #2021:
URL: https://github.com/apache/iggy/pull/2021#discussion_r2224110426


##########
bdd/go/tests/basic_messaging_test.go:
##########
@@ -0,0 +1,351 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package tests
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	iggcon "github.com/apache/iggy/foreign/go/contracts"
+	"github.com/apache/iggy/foreign/go/iggycli"
+	"github.com/apache/iggy/foreign/go/tcp"
+	"github.com/cucumber/godog"
+	"github.com/google/uuid"
+	"os"
+	"testing"
+)
+
+type (
+	serverAddrKeyType          struct{}
+	clientKeyType              struct{}
+	lastSentMessageKeyType     struct{}
+	lastPollMessagesKeyType    struct{}
+	lastStreamIDKeyType        struct{}
+	lastStreamNameKeyType      struct{}
+	lastTopicIDKeyType         struct{}
+	lastTopicNameKeyType       struct{}
+	lastTopicPartitionsKeyType struct{}
+)
+
+var (
+	ServerAddrKey          = serverAddrKeyType{}
+	ClientKey              = clientKeyType{}
+	LastSentMessageKey     = lastSentMessageKeyType{}
+	LastPollMessagesKey    = lastPollMessagesKeyType{}
+	LastStreamIDKey        = lastStreamIDKeyType{}
+	LastStreamNameKey      = lastStreamNameKeyType{}
+	LastTopicIDKey         = lastTopicIDKeyType{}
+	LastTopicNameKey       = lastTopicNameKeyType{}
+	LastTopicPartitionsKey = lastTopicPartitionsKeyType{}
+)
+
+func givenRunningServer(ctx context.Context) (context.Context, error) {
+	addr := os.Getenv("IGGY_TCP_ADDRESS")
+	if addr == "" {
+		addr = "127.0.0.1:8090"
+	}
+	return context.WithValue(ctx, ServerAddrKey, addr), nil
+}
+func givenAuthenticationAsRoot(ctx context.Context) (context.Context, error) {
+	serverAddr := ctx.Value(ServerAddrKey).(string)

Review Comment:
   Since the bdd repo is still small, we can keep storing values in the context for now. However, to be honest, I’m not a big fan of this approach because we can’t really see what’s stored in the go context - there’s a certain lack of clarity and transparency here.
   
   I suggest we leave it as is for the time being, but if the bdd coverage grows in the future, we can revisit this approach. For example, we could eventually introduce a structure similar to GlobalContext from the rust implementation, which would be stored in the context (likely as a single struct instead of multiple separate keys)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org