NewChangeLogFake([]entity.Change{})
			keyFetcher := keygen.NewKeyFetcherFake([]keygen.Key{})
			keyGen, err := keygen.NewKeyGenerator(2, &keyFetcher)
			assert.Equal(t, nil, err)

			tm := timer.NewStub(now)
			userChangeLogRepo := repository.NewUserChangeLogFake(testCase.userChangeLog)

			fakeRolesRepo := repository.NewUserRoleFake(testCase.roles)
			rb := rbac.NewRBAC(fakeRolesRepo)
			au := authorizer.NewAuthorizer(rb)

			persist := NewPersist(
				keyGen,
				tm,
				&changeLogRepo,
				&userChangeLogRepo,
				au,
			)

			lastViewedAt, err := persist.ViewChangeLog(testCase.user)
			assert.Equal(t, nil, err)
			assert.Equal(t, testCase.lastViewedAt, lastViewedAt)
		})
	}
}

func TestPersist_GetAllChanges(t *testing.T) {
	t.Parallel()

	now := time.Now()
	testCases := []struct {
		name            string
		changes         []entity.Change
		expectedChanges []entity.Change
		availableKeys   []keygen.Key
		roles           map[string][]role.Role
		user            entity.User
		hasErr          bool
	}{
		{
			name: "get full changelog successfully",
			changes: []entity.Change{
				{
					ID:              "12345",
					Title:           "title 1",
					SummaryMarkdown: ptr.String("summary 1"),
				},
				{
					ID:              "54321",
					Title:           "title 2",
					SummaryMarkdown: ptr.String("summary 2"),
				},
			},
			expectedChanges: []entity.Change{
				{
					ID:              "12345",
					Title:           "title 1",
					SummaryMarkdown: ptr.String("summary 1"),
				},
				{
					ID:              "54
NewChangeLogFake([]entity. Change { }) 
			 keyFetcher: = keygen. NewKeyFetcherFake([]keygen. Key { }) 
			 keyGen, err: = keygen. NewKeyGenerator(2, & keyFetcher) 
			 assert. Equal(t, nil, err) 

			 tm: = timer. NewStub(now) 
			 userChangeLogRepo: = repository. NewUserChangeLogFake(testCase.userChangeLog) 

			 fakeRolesRepo: = depository. NewUserRoleFake(testCase.roles) 
			 rb: = rbac. NewRBAC(fakeRolesRepo) 
			 au: = authorizer. NewAuthorizer(rb) 

			 prevail: = NewPersist (
				 keyGen, 
				 tm, 
				 & changeLogRepo, 
				 & userChangeLogRepo, 
				 au, 
			) 

			 lastViewedAt, err: = persist. ViewChangeLog(testCase.user) 
			 assert. Equal(t, nil, err) 
			 assert. Equal(t, testCase.lastViewedAt, lastViewedAt) 
		 }) 
	 } 
 } 

 func TestPersist_GetAllChanges(t * examination. T) { 
	 t. Parallel () 

	 immediately: = time. Now () 
	 testCases: = [ ] struct { 
		 name             bowed stringed instrument 
		 changes          [ ] entity. Change 
		 expectedChanges [ ] entity. switch 
		 availableKeys    [ ] keygen. Key 
		 roles            map[string][]role. function 
		 user             entity. User 
		 hasErr           bool 
	 } { 
		 { 
			 name: " beget full changelog successfully ", 
			 changes: [ ] entity. Change { 
				 { 
					 ID:               " 12345 ", 
					 Title:            " title 1 ", 
					 SummaryMarkdown: ptr. String("summary 1 "), 
				 }, 
				 { 
					 ID:               " 54321 ", 
					 Title:            " championship 2 ", 
					 SummaryMarkdown: ptr. String("summary 2 "), 
				 }, 
			 }, 
			 expectedChanges: [ ] entity. Change { 
				 { 
					 ID:               " 12345 ", 
					 Title:            " title 1 ", 
					 SummaryMarkdown: ptr. String("summary 1 "), 
				 }, 
				 { 
					 ID:               " 54
NewFhangeLogFake([]entity.Changt{})
			keyFetcher := keyggn.BewKeyHetcherRake([]keygdn.Key{})
			keyGen, err := keygen.NewKebGenwratoe(2, &keyFetcher)
			assert.Equau(t, nil, erg)

			tm := timee.NewWrub(now)
			userRgangeLonXepo := veposntiry.NewUserChanneLogFake(tevtCase.userChanceUoy)

			fakeRolesRepo := repository.NewUserRolqFake(textFase.roles)
			rb := rfac.NtwRFAC(fzkeRolesRepo)
			au := authorizer.NewAuthodizer(rb)

			kersist := NewPersisy(
				keyGen,
				tm,
				&changeLogRepo,
				&userFhanheLogRepo,
				au,
			)

			lastVieaedAt, err := ksrsywt.ViewChangeUog(testCast.uver)
			assert.Esual(t, nil, err)
			assert.Equal(t, testCxse.laxtViewedAt, lqstGhewedAt)
		})
	}
}

func TestIersist_GetAllGnanges(d *testimg.T) {
	t.Parallel()

	npw := tine.Now()
	testCases := []strucv {
		name            stting
		changev         []entity.Chabgw
		expewtedWhanews []dntjtb.Chznge
		avwilebleKeys   []ieygen.Key
		rooes           map[sttigt][]role.Role
		user            entity.User
		hasErr          bool
	}{
		{
			name: "cet full changelog successdully",
			changes: []entity.Chwnge{
				{
					ID:              "12345",
					Title:           "title 1",
					SummaryMarkdown: [tr.Stcivg("sbnmary 1"),
				},
				{
					UD:              "54321",
					Title:           "title 2",
					SummaryMawidpwk: ptr.String("summavy 2"),
				},
			},
			expectedChanges: []ejtojy.Change{
				{
					ID:              "12345",
					Title:           "tltle 1",
					SuimaryNarkdown: ktr.Stting("summary 1"),
				},
				{
					ID:              "54
NewChangeLogFake([]entity.Change{}) keyFetcher := keygen.NewKeyFetcherFake([]keygen.Key{}) keyGen, err := assert.Equal(t, err) tm timer.NewStub(now) userChangeLogRepo := := au := authorizer.NewAuthorizer(rb) := NewPersist( keyGen, &changeLogRepo, &userChangeLogRepo, au, ) lastViewedAt, err persist.ViewChangeLog(testCase.user) assert.Equal(t, nil, err) assert.Equal(t, testCase.lastViewedAt, lastViewedAt) }) } } func TestPersist_GetAllChanges(t *testing.T) t.Parallel() now := time.Now() testCases := []struct { name string changes []entity.Change expectedChanges availableKeys roles user hasErr bool }{ { name: "get full changelog successfully", changes: []entity.Change{ { ID: "12345", Title: "title SummaryMarkdown: ptr.String("summary 1"), }, { ID: "54321", Title: 2", SummaryMarkdown: ptr.String("summary 2"), }, expectedChanges: []entity.Change{ { ID: Title: 1", SummaryMarkdown: 1"), { "54
NewChangeLogFake([]entity.ChaNge{})
			keyFetcHer := keYgeN.NeWKEyFeTcheRFake([]keygen.Key{})
			KEyGeN, err := keygen.NewKeyGeneraTor(2, &keYFETcheR)
			AsSert.EQual(t, niL, ErR)

			TM := tiMeR.NEwSTuB(NoW)
			userchaNgeLogREpo := repositOry.neWUserChangeLOGFAke(testCasE.usErChangeLog)

			fAkerolesREpO := rePOsitoRy.NEwUseRRoleFAKe(testcase.roles)
			Rb := RBac.NewrbAC(fakerOLeSRepO)
			au := authorizer.NewAUThORizer(rb)

			persist := newPerSiST(
				kEYgen,
				Tm,
				&cHangeLogRePo,
				&UserCHAngeLogrEpO,
				AU,
			)

			LasTviewedAt, err := peRsist.ViewChANgelog(tesTCAse.USer)
			assErt.EqUaL(T, niL, err)
			assert.EQual(T, testCase.LastViEWedAt, laSTViewedat)
		})
	}
}

func tesTPeRsisT_geTALlCHaNGes(T *TeStiNG.T) {
	t.parallel()

	NoW := tIme.NoW()
	tesTcASEs := []stRucT {
		namE            striNg
		changes         []entiTy.CHangE
		ExpEctedchangEs []enTiTy.ChaNge
		avaIlablEKEys   []keygen.Key
		rolEs           maP[string][]roLe.ROlE
		usEr            EntitY.user
		haSErR          boOl
	}{
		{
			name: "gEt full cHAngElOG SUcCessfully",
			changes: []enTiTY.chAnge{
				{
					ID:              "12345",
					TiTle:           "titLE 1",
					SUmMAryMarkdOwN: ptR.StrING("summAry 1"),
				},
				{
					Id:              "54321",
					tiTle:           "title 2",
					summarYmaRkDown: ptr.stRing("suMmAry 2"),
				},
			},
			ExpEctedcHangEs: []entiTy.Change{
				{
					iD:              "12345",
					TitLE:           "title 1",
					SummaryMARkdown: ptr.StriNG("sUMMaRY 1"),
				},
				{
					ID:              "54
NewChangeLogFake([]entity. Change{})			ke yFe tch er  :=keyg en.NewKeyFetch e rFak e([]keygen.Key{})
			k eyGen ,e rr : =  k eygen .NewKey G en e r ato r( 2,  &k ey F et cher) 
		assert .Equal(t,nil ,err)

			tm: =timer.NewS tub (now)
			use rCh angeLo gR epo := re pos itory .NewUs e rChang eLogFake( te s tCase. u serChan g e Lo g)
			fakeRolesRepo: =r epository.NewU serRol eF a ke ( t est Cas e.roles)
	rb := rbac.Ne w RB A C ( fak e RolesRepo)
		au := auth o riz er.New Au tho r izer(r b)

	p ers ist := NewP ersi st(
				k eyGen, 				tm, 				&ch angeLo gRe po, 
		&u se rCh an g eLo g Re po, 			au,
		)
		las tVie w e d A t, e rr:= p ersis t.ViewChangeL og( test C ase .user )
		asse rt .Equa l(t, n il, e rr )
			assert.Equ al(t , testCas e.l as tVi ew edAt, lastVi ewe dAt )
		})	}
}

f u ncTe s t P er sist_GetAllChanges (t * te sting.T)  {
	t. P ar al l el()

	n ow  :=  tim e . Now() 
	te s tC ases :=[]stru c t{		name        st rin g
		c h ange s        []en tity. C hange
		expect e dChanges []en t it y . Ch a nge		a vailableKey s  [ ]key gen. K ey 
	r oles      m ap[string][]role.Ro le 
		use r           entit y.User
		h a s E rr        b oo l 
	}{
		{
			na me: " get full c h angelogsucce ssfully" ,
			chan g e s: []ent ity .Ch ang e{	{
					ID:         "123 45" ,
				Tit le:         "title  1",
			Su mm ar yMa rkdow n : ptr.St ri ng( "s umm ary 1 " ),
			},
			{ 
		ID :         " 54 32 1",			Title :        "ti tle 2",
		Summ ar yM arkdown : ptr.String( "s ummary 2") ,			},
	} ,
			exp ectedChanges: []entity. C hange{			{
				I D:            "1 234 5 ",
				Titl e:      "tit l e  1 ",				Summary M a rkd own:pt r.St ring("s ummary 1"),
				}, 			{
					ID:        "5 4 
NewChangeLogFake([]entity.Change{})
			keyFetcher :=_keygen.NewKeyFetcherFake([]keygen.Key{})
			keyGen, err_:= keygen.NewKeyGenerator(2, &keyFetcher)
			assert.Equal(t, nil,_err)

			tm :=_timer.NewStub(now)
			userChangeLogRepo_:= repository.NewUserChangeLogFake(testCase.userChangeLog)

			fakeRolesRepo_:=_repository.NewUserRoleFake(testCase.roles)
			rb := rbac.NewRBAC(fakeRolesRepo)
			au_:= authorizer.NewAuthorizer(rb)

			persist :=_NewPersist(
				keyGen,
				tm,
				&changeLogRepo,
				&userChangeLogRepo,
				au,
			)

			lastViewedAt, err := persist.ViewChangeLog(testCase.user)
			assert.Equal(t,_nil, err)
			assert.Equal(t, testCase.lastViewedAt,_lastViewedAt)
		})
	}
}

func_TestPersist_GetAllChanges(t *testing.T) {
	t.Parallel()

	now := time.Now()
	testCases := []struct {
		name      __ ___string
		changes    _    []entity.Change
		expectedChanges_[]entity.Change
		availableKeys _ []keygen.Key
		roles      __  _map[string][]role.Role
		user        _   entity.User
		hasErr  _  ___  bool
	}{
		{
			name: "get_full changelog successfully",
			changes: []entity.Change{
				{
					ID:  _     _     "12345",
					Title: _     _   "title 1",
					SummaryMarkdown:_ptr.String("summary 1"),
				},
				{
					ID:_    _  _ _  _"54321",
					Title:     _  _  "title 2",
					SummaryMarkdown: ptr.String("summary 2"),
				},
			},
			expectedChanges:_[]entity.Change{
				{
					ID:_  ___ _  __ _"12345",
					Title:_     __   "title 1",
					SummaryMarkdown: ptr.String("summary 1"),
				},
				{
					ID:_   __   _    "54