<commit_before>package base

import (
	"fmt"
	"log"
	"testing"

	"github.com/couchbase/gocb"
	"github.com/couchbaselabs/go.assert"
)

func TestN1qlQuery(t *testing.T) {

	if UnitTestUrlIsWalrus() {
		t.Skip("This test only works against Couchbase Server")
	}

	testBucket := GetTestBucketOrPanic()
	defer testBucket.Close()
	bucket, ok := testBucket.Bucket.(*CouchbaseBucketGoCB)
	if !ok {
		t.Fatalf("Requires gocb bucket")
	}

	// Write a few docs to the bucket to query
	for i := 0; i < 5; i++ {
		key := fmt.Sprintf("doc%d", i)
		body := fmt.Sprintf(`{"val": %d}`, i)
		added, err := bucket.AddRaw(key, 0, []byte(body))
		if err != nil {
			t.Errorf("Error adding doc for TestN1qlQuery: %v", err)
		}
		assertTrue(t, added, "AddRaw returned added=false, expected true")
	}

	indexExpression := "val"
	err := bucket.CreateIndex("testIndex_value", indexExpression, 0)
	if err != nil {
		t.Errorf("Error creating index: %s", err)
	}

	// Check index state
	exists, state, stateErr := bucket.GetIndexMeta("testIndex_value")
	assertNoError(t, stateErr, "Error validating index state")
	assert.Equals(t, state, "online")
	assert.Equals(t, exists, true)
<commit_msg>Fix TestN1qlQuery integration test error<commit_after>package base

import (
	"fmt"
	"log"
	"testing"

	"github.com/couchbase/gocb"
	"github.com/couchbaselabs/go.assert"
)

func TestN1qlQuery(t *testing.T) {

	if UnitTestUrlIsWalrus() {
		t.Skip("This test only works against Couchbase Server")
	}

	testBucket := GetTestBucketOrPanic()
	defer testBucket.Close()
	bucket, ok := testBucket.Bucket.(*CouchbaseBucketGoCB)
	if !ok {
		t.Fatalf("Requires gocb bucket")
	}

	// Write a few docs to the bucket to query
	for i := 0; i < 5; i++ {
		key := fmt.Sprintf("doc%d", i)
		body := fmt.Sprintf(`{"val": %d}`, i)
		added, err := bucket.AddRaw(key, 0, []byte(body))
		if err != nil {
			t.Errorf("Error adding doc for TestN1qlQuery: %v", err)
		}
		assertTrue(t, added, "AddRaw returned added=false, expected true")
	}

	indexExpression := "val"
	err := bucket.CreateIndex("testIndex_value", indexExpression, 0)
	if err != nil {
		t.Errorf("Error creating index: %s", err)
	}

	// Check index state
	exists, state, stateErr := bucket.GetIndexMeta("testIndex_value")
	assertNoError(t, stateErr, "Error validating index state")
	assert.Equals(t, state.State, "online")
	assert.Equals(t, exists, true)

{'fraction_non_alphanumeric': 0.15218312844425605, 'fraction_numerical': 0.005510809665112336, 'mean_word_length': 4.412844036697248, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2452650', 'n_tokens_mistral': 901, 'n_tokens_neox': 858, 'n_words': 222}