_news__db_check_news_revision (private)

 _news__db_check_news_revision

Defined in packages/news/tcl/test/news-db-test-init.tcl

Partial Call Graph (max 5 caller/called nodes):
%3 aa_call_component aa_call_component (public) aa_equals aa_equals (public) aa_error aa_error (public) aa_false aa_false (public) aa_log aa_log (public) _news__db_check_news_revision _news__db_check_news_revision _news__db_check_news_revision->aa_call_component _news__db_check_news_revision->aa_equals _news__db_check_news_revision->aa_error _news__db_check_news_revision->aa_false _news__db_check_news_revision->aa_log

Testcases:
No testcase defined.
Source code:
        
            upvar 2 _aa_exports _aa_exports
            foreach init_class mount-news-package {
                if {[llength $init_class] == 2} {
                    lassign $init_class init_class init_package_key
                } else {
                    set init_package_key news
                }
                foreach v $_aa_exports([list $init_package_key $init_class]) {
                    upvar 2 $v $v
                }
                foreach logpair $::aa_init_class_logs([list $init_package_key $init_class]) {
                    aa_log_result [lindex $logpair 0] [lindex $logpair 1]
                }
            }
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{
    set news_id -1

    if {!$_news_package_mounted_p} {
        aa_error "News package not mounted, error from initializer: $_news_package_mounted_err"
    } else {
        #
        # Create the article
        #
        set p_title         "My title"
        set p_text          "My text"
        set p_package_id    $_news_package_id
        set p_is_live       "t"
        set p_full_details  "t"
        aa_call_component db-news-globals
        aa_call_component db-news-item-create
    }
} {
    aa_true "Check the news_id is populated" {$news_id != -1}
    set item_id -1
    set revision1_id -1
    set revision2_id -1
    if {$news_id != -1} {
        aa_log "News id: $news_id"
        #
        # Retrieve the row from cr_revisions table to get item_id
        #
        set p_revision_id $news_id
        aa_call_component db-get-cr-revisions-row
        set revision1_id $news_id

        #
        # Check the first revision is the latest, and is live.
        #
        set p_item_id $item_id
        aa_call_component db-news-get-live-revision
        aa_call_component db-news-get-latest-revision
        aa_equals "Confirm that the initial revision of the article is the latest"  $latest_revision_id $revision1_id
        aa_equals "Confirm that the initial revision of the article is live"  $live_revision_id $revision1_id

        #
        # Create a new revision of the news article.
        #
        set p_item_id                $item_id
        set p_title                  "My title 2"
        set p_text                   "My text 2"
        set p_description            "Description 2"
        set p_package_id             $_news_package_id
        set p_full_details           "t"
        set p_make_active_revision_p "t"
        aa_call_component db-news-revision-create
        set revision2_id $revision_id

        #
        # Retrieve the cr_news column for the new revision
        #
        set p_news_id $revision2_id
        aa_call_component db-get-cr-news-row
        if {!$retrieval_ok_p} {
            aa_error "cr_news row not found for new revision news_id $revision2_id"
        } else {
            aa_log "Check the cr_news fields for the second revision"
            aa_equals "Check package_id correct"    $package_id $_news_package_id
            aa_equals "Check archive_date correct"   [string range $archive_date 0 [string length $p_archive_date]-1]  $p_archive_date
            aa_equals "Check approval_user correct" $approval_user $p_approval_user
            aa_equals "Check approval_date correct"  [string range $approval_date 0 [string length $p_approval_date]-1]  $p_approval_date
            aa_equals "Check approval_ip correct"   $approval_ip $p_approval_ip

            #
            # Retrieve the row from cr_revisions table to get item_id
            #
            set p_revision_id $revision2_id
            aa_call_component db-get-cr-revisions-row
            if {!$retrieval_ok_p} {
                aa_error "cr_revisions row not found for new revision revision_id $revision2_id"
            } else {
                aa_equals "Check revision2 title correct"       $title       "My title 2"
                aa_equals "Check revision2 description correct" $description "Description 2"
                aa_equals "Check revision2 mime_type correct"   $mime_type   "text/plain"

                #
                # Check the second revision is now the latest, and is live.
                #
                set p_item_id $item_id
                aa_call_component db-news-get-live-revision
                aa_call_component db-news-get-latest-revision
                aa_equals "Confirm that the second revision of the article is the latest"  $latest_revision_id $revision2_id
                aa_equals "Confirm that the second revision of the article is live"  $live_revision_id $revision2_id

                #
                # Okay, let's set the original revision as active.
                #
                aa_log "Reset the first revision as live"
                set p_revision_id $revision1_id
                aa_call_component db-news-revision-set-active

                #
                # Check the second revision is still the latest, but the first one is live.
                #
                set p_item_id $item_id
                aa_call_component db-news-get-live-revision
                aa_call_component db-news-get-latest-revision
                aa_equals "Confirm that the second revision of the article is still the latest"  $latest_revision_id $revision2_id
                aa_equals "Confirm that the first revision of the article is now live"  $live_revision_id $revision1_id

                #
                # Delete the second revision
                #
                aa_log "Delete the second revision"
                set p_revision_id $revision2_id
                aa_call_component db-news-revision-delete

                #
                # Retrieve the row from cr_revisions table to get item_id
                #
                set p_revision_id $revision2_id
                aa_call_component db-get-cr-revisions-row
                aa_false "Check the revision row was deleted" $retrieval_ok_p
            }
        }
    }
} {
    #
    # Delete the item.
    #
    if {$item_id != -1} {
        aa_log "Deleting item."
        set p_item_id $item_id
        aa_call_component db-news-item-delete
    }
}} {
          aa_log "Running testcase body $body_count"
          set ::__aa_test_indent [info level]
          set catch_val [catch $testcase_body msg]
          if {$catch_val != 0 && $catch_val != 2} {
              aa_log_result "fail" "db_check_news_revision (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo"
          }
          incr body_count
        }
Generic XQL file:
packages/news/tcl/test/news-db-test-init.xql

PostgreSQL XQL file:
packages/news/tcl/test/news-db-test-init-postgresql.xql

Oracle XQL file:
packages/news/tcl/test/news-db-test-init-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: