@@ -394,33 +394,44 @@ func TestGetArangoSearchViews(t *testing.T) {
394394 }
395395}
396396
397- // TestRemoveArangoSearchView creates an arangosearch view and then removes it.
398- func TestRemoveArangoSearchView (t * testing.T ) {
397+ // TestRenameAndRemoveArangoSearchView creates an arangosearch view and then removes it.
398+ func TestRenameAndRemoveArangoSearchView (t * testing.T ) {
399399 ctx := context .Background ()
400400 c := createClientFromEnv (t , true )
401401 skipBelowVersion (c , "3.4" , t )
402402 db := ensureDatabase (ctx , c , "view_test" , nil , t )
403- name := "test_remove_asview "
403+ name := "test_rename_view "
404404 v , err := db .CreateArangoSearchView (ctx , name , nil )
405- if err != nil {
406- t .Fatalf ("Failed to create collection '%s': %s" , name , describe (err ))
407- }
405+ require .NoError (t , err )
406+
408407 // View must exist now
409- if found , err := db .ViewExists (ctx , name ); err != nil {
410- t .Errorf ("ViewExists('%s') failed: %s" , name , describe (err ))
411- } else if ! found {
412- t .Errorf ("ViewExists('%s') return false, expected true" , name )
413- }
408+ found , err := db .ViewExists (ctx , name )
409+ require .NoError (t , err )
410+ require .True (t , found )
411+
412+ // Rename view
413+ newName := "test_rename_view_new"
414+ err = v .Rename (ctx , newName )
415+ require .NoError (t , err )
416+ require .Equal (t , newName , v .Name ())
417+
418+ // Renamed View must exist
419+ found , err = db .ViewExists (ctx , newName )
420+ require .NoError (t , err )
421+ require .True (t , found )
422+
414423 // Now remove it
415- if err : = v .Remove (ctx ); err != nil {
416- t . Fatalf ( "Failed to remove view '%s': %s" , name , describe ( err ) )
417- }
424+ err = v .Remove (ctx )
425+ require . NoError ( t , err )
426+
418427 // View must not exist now
419- if found , err := db .ViewExists (ctx , name ); err != nil {
420- t .Errorf ("ViewExists('%s') failed: %s" , name , describe (err ))
421- } else if found {
422- t .Errorf ("ViewExists('%s') return true, expected false" , name )
423- }
428+ found , err = db .ViewExists (ctx , name )
429+ require .NoError (t , err )
430+ require .False (t , found )
431+
432+ found , err = db .ViewExists (ctx , newName )
433+ require .NoError (t , err )
434+ require .False (t , found )
424435}
425436
426437// TestUseArangoSearchView tries to create a view and actually use it in
0 commit comments