package repository_ddb

import (
	"context"
	"dataservices/ddb"
	"dataservices/internal/entity"
	"fmt"
	"testing"
)

func TestGetDataAppByExtId(t *testing.T) {
	type args struct {
		appExtId string
	}
	tests := []struct {
		name    string
		args    args
		want    *entity.DataApp
		wantErr bool
	}{
		{
			name: "OK",
			args: args{
				appExtId: "dataapi-GvgkpysR",
			},
			want: &entity.DataApp{
				ID: 1200001,
			},
			wantErr: false,
		},
	}
	ctx := context.Background()
	client, err := ddb.NewDynamodbClient(ctx, "us-west-2")
	if err != nil {
		t.Errorf("NewDynamodbClient() error = %v", err)
		return
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got, err := GetDataAppByExtId(ctx, client, tt.args.appExtId)
			fmt.Printf("%+v\n", got)
			if (err != nil) != tt.wantErr {
				t.Errorf("GetDataAppByExtId() error = %v, wantErr %v", err, tt.wantErr)
				return
			}
			if got.ID != tt.want.ID {
				t.Errorf("GetDataAppByExtId() = %v, want %v", got, tt.want)
			}
		})
	}
}
