You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: index_usage_stats_rec_test.go
    path of file: ./repos/cockroach/pkg/sql/idxusage
    
    the code of the file until where you have to start completion: // Copyright 2022 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licens
    
func TestGetRecommendationsFromIndexStats(t *testing.T) {

	var currentTime = timeutil.Now()
	var anHourBefore = currentTime.Add(-time.Hour)
	var aMinuteBefore = currentTime.Add(-time.Minute)

	/*
		Test cases:
			- system db name
			- index type primary
			- drop unused rec
			- drop never used rec
			- recently used index
			- secondary unique index
	*/

	testData := []struct {
		idxStats            IndexStatsRow
		dbName              string
		unusedIndexDuration time.Duration
		expectedReturn      []*serverpb.IndexRecommendation
	}{
		// Database name "system", expect no index recommendation.
		{
			idxStats: IndexStatsRow{
				TableID:          1,
				IndexID:          2,
				LastRead:         anHourBefore,
				IndexType:        "secondary",
				IsUnique:         false,
				CreatedAt:        nil,
				UnusedIndexKnobs: nil,
			},
			dbName:              "system",
			unusedIndexDuration: time.Hour,
			expectedReturn:      []*serverpb.IndexRecommendation{},
		},
		// Index is primary index, expect no index recommendation.
		{
			idxStats: IndexStatsRow{
				TableID:          1,
				IndexID:          2,
				LastRead:         anHourBefore,
				CreatedAt:        nil,
				UnusedIndexKnobs: nil,
				IndexType:        "primary",
				IsUnique:         true,
			},
			dbName:              "testdb",
			unusedIndexDuration: time.Hour,
			expectedReturn:      []*serverpb.IndexRecommendation{},
		},
		// Index exceeds the unused index duration, expect index recommendation.
		{
			idxStats: IndexStatsRow{
				TableID:          1,
				IndexID:          2,
				LastRead:         anHourBefore,
				IndexType:        "secondary",
				IsUnique:         false,
				CreatedAt:        nil,
				UnusedIndexKnobs: nil,
			},
			dbName:              "testdb",
			unusedIndexDuration: time.Hour,
			expectedReturn: []*serverpb.IndexRecommendation{
				{
					TableID: 1,
					IndexID: 2,
					Type:    serverpb.IndexRecommendation_DROP_UNUSED,
					Reason:  "This index has not been used in over 1 hours, and can be removed for better write performance.",
				},
			},
		},
		// Index has never been used and has no creation time, expect never used index recommendation.
		{
			idxStats: IndexStatsRow{
				TableID:          1,
				IndexID:          3,
				LastRead:         time.Time{},
				IndexType:        "secondary",
				IsUnique:         false,
				CreatedAt:        nil,
				UnusedIndexKnobs: nil,
			},
			dbName:              "testdb",
			unusedIndexDuration: defaultUnusedIndexDuration,
			expectedReturn: []*serverpb.IndexRecommendation{
				{
					TableID: 1,
					IndexID: 3,
					Type:    serverpb.IndexRecommendation_DROP_UNUSED,
					Reason:  indexNeverUsedReason,
				},
			},
		},
		// Index has been used recently, expect no index recommendations.
		{
			idxStats: IndexStatsRow{
				TableID:          1,
				IndexID:          4,
				LastRead:         aMinuteBefore,
				IndexType:        "secondary",
				IsUnique:         false,
				CreatedAt:        nil,
				UnusedIndexKnobs: nil,
			},
			dbName:              "testdb",
			unusedIndexDuration: defaultUnusedIndexDuration,
			expectedReturn:      []*serverpb.IndexRecommendation{},
		},
		// Index exceeds the unused index duration, but is unique, so expect no index recommendation.
		{
			idxStats: IndexStatsRow{
				TableID:          1,
				IndexID:          5,
				LastRead:         anHourBefore,
				IndexType:        "secondary",
				IsUnique:         true,
				CreatedAt:        nil,
				UnusedIndexKnobs: nil,
			},
			dbName:              "testdb",
			unusedIndexDuration: time.Hour,
			expectedReturn:      []*serverpb.IndexRecommendation{},
		},
	}

	st := cluster.MakeTestingClusterSettings()
	for _, tc := range testData {
		DropUnusedIndexDuration.Override(context.Background(), &st.SV, tc.unusedIndexDuration)
		actualReturn := tc.idxStats.GetRecommendationsFromIndexStats(tc.dbName, st)
		require.Equal(t, tc.expectedReturn, actualReturn)
	}
}