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: digest_test.go
    path of file: ./repos/magma/lte/cloud/go/services/subscriberdb
    
    the code of the file until where you have to start completion: /*
Copyright 2020 The Magma Authors.

This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.

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 subscriberdb_test

import (
	"context"
	"fmt"
	"testing"

	"github.com/stretchr/testify/assert"

	"magma/lte/cloud/go/lte"
	"magma/lte/cloud/go/serdes"
	lte_models "magma/lte/cloud/go/services/lte/obsidian/models"
	lte_test_init "magma/lte/cloud/go/services/lte/test_init"
	"magma/lte/cloud/go/services/subscriberdb"
	"magma/lte/cloud/go/services/subscriberdb/obsidian/models"
	"magma/orc8r/cloud/go/orc8r"
	"magma/orc8r/cloud/go/services/configurator"
	configurator_test_init "magma/orc8r/cloud/go/services/configurator/test_init"
	"magma/orc8r/cloud/go/storage"
	"magma/orc8r/lib/go/protos"
)

func TestGetDigestDeterministic(t *testing.T) {
	lte_test_init.StartTestService(t)
	configurator_test_init.StartTestService(t)

	err := configurator.CreateNetwork(context.Background(), configurator.Network{ID: "n1"}, serdes.Network)
	assert.NoError(t, err)
	_, err = configurator.CreateEntity(context.Background(), "n1", configurator.NetworkEntity{Type: orc8r.MagmadGatewayType, Key: "g1", PhysicalID: "hw1"}, serdes.Entity)
	assert.NoError(t, err)
	gw, err := 
    
func TestGetPerSubscriberDigests(t *testing.T) {
	lte_test_init.StartTestService(t)
	configurator_test_init.StartTestService(t)

	err := configurator.CreateNetwork(context.Background(), configurator.Network{ID: "n1"}, serdes.Network)
	assert.NoError(t, err)
	gw, err := configurator.CreateEntity(context.Background(), "n1", configurator.NetworkEntity{Type: lte.CellularGatewayEntityType, Key: "g1"}, serdes.Entity)
	assert.NoError(t, err)

	perSubDigests, err := subscriberdb.GetPerSubscriberDigests("n1")
	assert.NoError(t, err)
	// The generated leaf digests list should be empty but not nil, to avoid unexpected errors
	// when the agw client iterates over this list returned from cloud
	assert.Equal(t, []*protos.LeafDigest{}, perSubDigests)

	// Generate individual digests for each newly detected subscriber in the network
	_, err = configurator.CreateEntities(context.Background(), "n1", configurator.NetworkEntities{
		configurator.NetworkEntity{
			Type: lte.SubscriberEntityType, Key: "IMSI00001",
			Config: &models.SubscriberConfig{
				Lte: &models.LteSubscription{State: "ACTIVE"},
			},
		},
		configurator.NetworkEntity{
			Type: lte.SubscriberEntityType, Key: "IMSI00002",
			Config: &models.SubscriberConfig{
				Lte: &models.LteSubscription{State: "ACTIVE"},
			},
		},
		configurator.NetworkEntity{
			Type: lte.APNEntityType, Key: "apn",
			Config: &lte_models.ApnConfiguration{},
		},
	}, serdes.Entity)
	assert.NoError(t, err)

	perSubDigests, err = subscriberdb.GetPerSubscriberDigests("n1")
	assert.NoError(t, err)
	assert.Len(t, perSubDigests, 2)
	assert.Equal(t, "IMSI00001", perSubDigests[0].Id)
	assert.NotEmpty(t, perSubDigests[0].Digest.Md5Base64Digest)
	assert.Equal(t, "IMSI00002", perSubDigests[1].Id)
	assert.NotEmpty(t, perSubDigests[1].Digest.Md5Base64Digest)
	digestSub1 := perSubDigests[0].Digest.Md5Base64Digest

	_, err = configurator.CreateEntity(context.Background(), "n1", configurator.NetworkEntity{
		Type: lte.SubscriberEntityType, Key: "IMSI00003",
		Config: &models.SubscriberConfig{
			Lte: &models.LteSubscription{State: "ACTIVE"},
		},
	}, serdes.Entity)
	assert.NoError(t, err)
	err = configurator.DeleteEntity(context.Background(), "n1", lte.SubscriberEntityType, "IMSI00001")
	assert.NoError(t, err)
	err = configurator.DeleteEntity(context.Background(), "n1", lte.SubscriberEntityType, "IMSI00002")
	assert.NoError(t, err)
	_, err = configurator.CreateEntity(context.Background(), "n1", configurator.NetworkEntity{
		Type: lte.SubscriberEntityType, Key: "IMSI00001",
		Config: &models.SubscriberConfig{
			Lte: &models.LteSubscription{State: "INACTIVE"},
		},
	}, serdes.Entity)
	assert.NoError(t, err)

	// Detect changes in subscriber data and reflect them in the generated digests
	perSubDigests, err = subscriberdb.GetPerSubscriberDigests("n1")
	assert.NoError(t, err)
	assert.Len(t, perSubDigests, 2)
	assert.Equal(t, "IMSI00001", perSubDigests[0].Id)
	assert.NotEqual(t, digestSub1, perSubDigests[0].Digest.Md5Base64Digest)
	assert.Equal(t, "IMSI00003", perSubDigests[1].Id)
	assert.NotEmpty(t, perSubDigests[1].Digest.Md5Base64Digest)
	digestSub1 = perSubDigests[0].Digest.Md5Base64Digest
	digestSub3 := perSubDigests[1].Digest.Md5Base64Digest

	var writes []configurator.EntityWriteOperation
	writes = append(writes, configurator.NetworkEntity{
		NetworkID: "n1",
		Type:      lte.APNResourceEntityType,
		Key:       "resource",
		Config: &lte_models.ApnResource{
			ApnName:    "apn",
			GatewayIP:  "172.16.254.1",
			GatewayMac: "00:0a:95:9d:68:16",
			ID:         "resource",
			VlanID:     42,
		},
		Associations: storage.TKs{{Type: lte.APNEntityType, Key: "apn"}},
	})
	write := configurator.EntityUpdateCriteria{
		Type:              lte.CellularGatewayEntityType,
		Key:               gw.Key,
		AssociationsToAdd: storage.TKs{{Type: lte.APNResourceEntityType, Key: "resource"}},
	}
	writes = append(writes, write)
	err = configurator.WriteEntities(context.Background(), "n1", writes, serdes.Entity)
	assert.NoError(t, err)

	// Detect changes in apn resources data and reflect them in the ENTIRE set of generated digests
	perSubDigests, err = subscriberdb.GetPerSubscriberDigests("n1")
	assert.NoError(t, err)
	assert.Len(t, perSubDigests, 2)
	assert.Equal(t, "IMSI00001", perSubDigests[0].Id)
	assert.NotEqual(t, digestSub1, perSubDigests[0].Digest.Md5Base64Digest)
	assert.Equal(t, "IMSI00003", perSubDigests[1].Id)
	assert.NotEqual(t, digestSub3, perSubDigests[1].Digest.Md5Base64Digest)
}