<commit_before>package lib

import (
	"reflect"
	"testing"

	_ "v.io/core/veyron/profiles"
	google_rt "v.io/core/veyron/runtimes/google/rt"
	mocks_ipc "v.io/core/veyron/runtimes/google/testing/mocks/ipc"
	"v.io/core/veyron2/context"
	"v.io/core/veyron2/vdl"
	"v.io/core/veyron2/vdl/vdlroot/src/signature"
)

const (
	name = "/veyron/name"
)

func wantSignature() []signature.Interface {
	return []signature.Interface{
		{
			Methods: []signature.Method{
				{
					Name:    "Method1",
					InArgs:  []signature.Arg{{Type: vdl.StringType}},
					OutArgs: []signature.Arg{{Type: vdl.ErrorType}},
				},
			},
		},
	}
}

func initContext(t *testing.T) (*context.T, *mocks_ipc.SimpleMockClient) {
	client := mocks_ipc.NewSimpleClient(
		map[string][]interface{}{
			"__Signature": []interface{}{wantSignature(), nil},
		},
	)
	// The NewUninitializedContext call takes a runtime as its argument, which is
	// used to set the runtime in the context.  None of our tests actually use the
	// runtime, so we set an obviously bad value.
	dummyRuntime := "ThisIsNotAnActualRuntime"
	ctx := context.NewUninitializedContext(dummyRuntime)
	ctx = google_rt.SetClient(ctx, client)
	return ctx, client
}

func TestFetching(t *testing.T) {
	ctx, _ := initContext(t)

	sm := NewSignatureManager()
	got, err := sm.Signature(ctx, name)
	if err != nil {
		t.Errorf(`Did not expect an error but got %v`, err)
		return
	}
	if want := wantSignature(); !reflect.DeepEqual(got, want) {
		t.Errorf(`Signature got %v, want %v`, got, want)
	}
}

func TestThatCachedAfterFetching(t *testing.T) {<commit_msg>wspr: Remove the runtime from the context.  It is no longer needed.<commit_after>package lib

import (
	"reflect"
	"testing"

	_ "v.io/core/veyron/profiles"
	google_rt "v.io/core/veyron/runtimes/google/rt"
	mocks_ipc "v.io/core/veyron/runtimes/google/testing/mocks/ipc"
	"v.io/core/veyron2/context"
	"v.io/core/veyron2/vdl"
	"v.io/core/veyron2/vdl/vdlroot/src/signature"
)

const (
	name = "/veyron/name"
)

func wantSignature() []signature.Interface {
	return []signature.Interface{
		{
			Methods: []signature.Method{
				{
					Name:    "Method1",
					InArgs:  []signature.Arg{{Type: vdl.StringType}},
					OutArgs: []signature.Arg{{Type: vdl.ErrorType}},
				},
			},
		},
	}
}

func initContext(t *testing.T) (*context.T, *mocks_ipc.SimpleMockClient) {
	client := mocks_ipc.NewSimpleClient(
		map[string][]interface{}{
			"__Signature": []interface{}{wantSignature(), nil},
		},
	)

	var ctx *context.T
	ctx = google_rt.SetClient(ctx, client)
	return ctx, client
}

func TestFetching(t *testing.T) {
	ctx, _ := initContext(t)

	sm := NewSignatureManager()
	got, err := sm.Signature(ctx, name)
	if err != nil {
		t.Errorf(`Did not expect an error but got %v`, err)
		return
	}
	if want := wantSignature(); !reflect.DeepEqual(got, want) {
		t.Errorf(`Signature got %v, want %v`, got, want)
	}
}

func TestThatCachedAfterFetching(t *testing.T) {
{'fraction_non_alphanumeric': 0.15726495726495726, 'fraction_numerical': 0.002735042735042735, 'mean_word_length': 4.018867924528302, 'pattern_counts': {'":': 2, '<': 3, '<?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': '5002309', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1098, 'n_words': 226}